无法在 python 中 运行 乌龟 class
Unable to run turtle class in python
我收到以下错误:
Traceback (most recent call last):
File "C:/Users/yashg/AppData/Local/Programs/Python/Python36-32/turtle2.py", line 1, in <module>
import turtle
File "C:/Users/yashg/AppData/Local/Programs/Python/Python36-32\turtle.py", line 18, in <module>
draw_square()
File "C:/Users/yashg/AppData/Local/Programs/Python/Python36-32\turtle.py", line 3, in draw_square
window=turtle.Screen()
AttributeError: module 'turtle' has no attribute 'Screen'
您应该重命名您的脚本而不是 turtle.py
。否则它会阻止标准库的导入turtle
;首先搜索并导入您的模块,而不是标准库。
还要确保目录 C:\Users\yashg\AppData\Local\Programs\Python\Python36-32
中没有 turtle.pyc
。
我收到以下错误:
Traceback (most recent call last):
File "C:/Users/yashg/AppData/Local/Programs/Python/Python36-32/turtle2.py", line 1, in <module>
import turtle
File "C:/Users/yashg/AppData/Local/Programs/Python/Python36-32\turtle.py", line 18, in <module>
draw_square()
File "C:/Users/yashg/AppData/Local/Programs/Python/Python36-32\turtle.py", line 3, in draw_square
window=turtle.Screen()
AttributeError: module 'turtle' has no attribute 'Screen'
您应该重命名您的脚本而不是 turtle.py
。否则它会阻止标准库的导入turtle
;首先搜索并导入您的模块,而不是标准库。
还要确保目录 C:\Users\yashg\AppData\Local\Programs\Python\Python36-32
中没有 turtle.pyc
。