我正在使用ThinkPython書籍學習python,我正在使用python 3.4和Anaconda IDE。部分我需要繼續的是安裝一個名爲swampy的模塊。我使用pip安裝了它,它工作得很好。導入模塊與tkinter一起工作,但我不能使用模塊中的任何功能。我檢查了我的lib文件夾,沼澤在那裏,功能也在沼澤地文件夾中。我無法弄清楚爲什麼它不起作用。請我真的需要幫助。如果問題不夠清楚,請告訴我。我已經包括了我試圖運行的代碼和錯誤消息,我嘗試運行它swampy.TurtleWorld不能在python中工作3.4
代碼中,我嘗試運行(29頁,認爲Python版本第四章蟒蛇3.4)
import tkinter
import swampy
world = swampy.TurtleWorld
bob = Turtle()
print(bob)
wait_for_user()
每次我得到
錯誤消息我得到
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Mbaka1\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 682, in runfile
execfile(filename, namespace)
File "C:\Users\Mbaka1\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 85, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "C:/Users/Mbaka1/Documents/Python Scripts/test.py", line 28, in <module>
world = swampy.TurtleWorld
AttributeError: 'module' object has no attribute 'TurtleWorld'
'wait_for_user'告訴TurtleWorld等待用戶執行某些操作,但在這種情況下,除了關閉窗口外,用戶不需要執行任何操作。 這就是它在書中所說的。我檢查了「wait_for_user.py」的沼澤文件夾,沒有看到任何文件。 – uchembaka