質問

I am trying to use a python import of turtle but i get an error:

Traceback (most recent call last):
  File "turtle.py", line 1, in <module>
    import turtle
  File "/turtle.py", line 32, in <module>
    turtle.pensize(2)
AttributeError: 'module' object has no attribute 'pensize'

Does the python come with turtle or i have to download it separately?

My python is 2.7.2

役に立ちましたか?

解決

You called your file turtle.py, so import turtle imports your program, not the module you want.

Rename your program and delete any turtle.py[co] files.

他のヒント

using turtle.py is causing the problem here. scrap that and use this instead

import turtle
turtlename = turtle.Turtle()
wn = turtle.Screen()

once you have done this use basic turtle comands like

turtlename.forward(90)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top