无法在python中运行turtle类

时间:2017-03-25 03:27:42

标签: python python-3.x class turtle-graphics

我收到以下错误:

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'

1 个答案:

答案 0 :(得分:1)

您应该重命名turtle.py以外的脚本。否则会阻止导入标准库turtle;首先搜索模块并导入模块而不是标准库。

还要确保目录turtle.pyc中没有C:\Users\yashg\AppData\Local\Programs\Python\Python36-32