2014-03-25 50 views
0
import turtle 
window = turtle.screen() 
myTurtle.forward(100) 
myTurtle.left(90) 
myTurtle.forward(100) 

window.mainloop() 

當我嘗試使用上面,而不是確保代碼爲什麼,因爲它同我的老師幻燈片,我只是想測試它,我得到這個錯誤爲了我自己。我不斷收到一個錯誤,當我嘗試和進口龜

Traceback (most recent call last): 
File "/Users/ruairimangan-cliff/Desktop/Foundations of Computer Programming/week 4/Week 4 'Functions'.py", line 72, in <module> 
window = turtle.screen() 
AttributeError: 'module' object has no attribute 'screen' 

回答

4

另外,如果你有同樣的問題,但沒有在

window = turtle.Screen() 

一個錯字,但您仍然收到錯誤消息:

AttributeError: 'module' object has no attribute 'Screen' 

您的腳本是否叫做turtle.py?

如果是這樣,它優先於標準庫中的烏龜模塊。 重命名您的腳本ála this answer

3

我也有這個問題。原來我命名我的文件turtle.py,與模塊衝突。只要我將它命名爲別的東西,它就會重新開始工作。

相關問題