下面是一段python代码,为什么一运行就提示TypeError: bad operand type for abs(): 'type'的错误
importturtledefdrawsnake(rad,angle,len,neckrad):foriinrange(len):turtle.circle(rad,ra...
import turtle
def drawsnake(rad, angle, len, neckrad):
for i in range(len):
turtle.circle(rad,range)
turtle.circle(-rad,range)
turtle.circle(rad,range/2)
turtle.fd(rad)
turtle.circle(neckrad+1,180)
turtle.fd(rad*2/3)
def main():
turtle.setup(1300,800,0,0)
pythonsize=30
turtle.pensize(pythonsize)
turtle.pencolor("blue")
turtle.seth(-40)
drawsnake(40,80,5,pythonsize/2)
main() 展开
def drawsnake(rad, angle, len, neckrad):
for i in range(len):
turtle.circle(rad,range)
turtle.circle(-rad,range)
turtle.circle(rad,range/2)
turtle.fd(rad)
turtle.circle(neckrad+1,180)
turtle.fd(rad*2/3)
def main():
turtle.setup(1300,800,0,0)
pythonsize=30
turtle.pensize(pythonsize)
turtle.pencolor("blue")
turtle.seth(-40)
drawsnake(40,80,5,pythonsize/2)
main() 展开
1个回答
展开全部
turtle.circle(rad,range)
turtle.circle(-rad,range)
turtle.circle(rad,range/2)
这三行不对,修改成
turtle.circle(rad,angle)
turtle.circle(-rad,angle)
turtle.circle(rad,angle/2)
turtle.circle(radius, extent=None, steps=None)
Parameters:
radius – a number
extent – a number (or None)
steps – an integer (or None)
第二个参数是角度是一个number
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询