我想在Python中使用turtle模塊。但是,當我做進口龜模塊,我以下錯誤:無法在Python 2.x和Python 3.x中導入turtle模塊
$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "turtle.py", line 3, in <module>
myTurtle = turtle.Turtle()
AttributeError: 'module' object has no attribute 'Turtle'
和Python 3.x都有:
$ python3
Python 3.2.3 (default, Sep 30 2012, 16:41:36)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import turtle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "turtle.py", line 3, in <module>
myTurtle = turtle.Turtle()
AttributeError: 'module' object has no attribute 'Turtle'
下我的Kubuntu的Linux 12.10工作。我和Tkinter gui一起玩過。沒有問題。烏龜模塊會發生什麼?
哦......我犯了一個愚蠢的錯誤。非常感謝你。 –
你能解釋一下嗎? – Stephan
當前目錄中有文件turtle.py。我嘗試導入烏龜模塊。和python解釋器搜索烏龜模塊,首先在我當前的文件夾中尋找turtle.py,而不是從python庫目錄中的turtle.py。 –