提问者:小点点

请帮助我看不懂的错误?


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

sides = input("Number of sides in polygon?"  )
length = input("Length of the sides in polygon?" )
colorname = input("Color of polygon?" )
Hcolor = input("Fill color of polygon?")

Kasey.pencolor(colorname)
Kasey.fillcolor(Hcolor)

Kasey.begin_fill()
for i in range(int(sides)):
  Kasey.forward (int(length))
  Kasey.left (int(360)/int(sides))

Kasey.end_fill()

错误:

Number of sides in polygon? 3
Length of the sides in polygon?5
Color of polygon?red
Fill color of polygon?blue

Traceback (most recent call last):

  File "<ipython-input-108-82ed860f1049>", line 1, in <module>
    runfile('/home/kasey/turtle.py', wdir='/home/kasey')

  File "/opt/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 668, in runfile
    execfile(filename, namespace)

  File "/opt/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 108, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "/home/kasey/turtle.py", line 18, in <module>
    Kasey.fillcolor(Hcolor)

TypeError: 'str' object is not callable

共1个答案

匿名用户

请在一个块中张贴一个更结构化的代码,而不仅仅是纯文本,它很难读懂。 我猜你有一个类或者只有一个名为'str'的文件,你没有在这里发布。 它可能有一个写错的构造函数,你能把它也贴在这里吗?