Python:5个缺少位置参数

时间:2018-10-27 03:58:15

标签: python function module

该函数的内部按需要工作,但是我不知道如何获取位置参数。该功能具有所有这些功能吗?

错误:

Traceback (most recent call last):
  File "/Users/Ironmomo/Documents/testingspirograph/test.py", line 31, in <module>
    drawCirclePattern()
TypeError: drawCirclePattern() missing 5 required positional arguments: 'centerX', 'centerY', 'offset', 'radius', and 'count'  

代码:

centerX = eval(input("Center x: "))
centerY = eval(input("Center y: "))
offset = eval(input("Offset: "))
count = eval(input("Count: "))
radius = eval(input("Radius: "))

def drawCirclePattern(centerX, centerY, offset, radius, count):
   import turtle
   turtle.goto(centerX, centerY)
   turtle.seth(0)
   countOG = count
   while count > 0:
        turtle.penup()
        turtle.fd(offset)
        turtle.pendown()
        turtle.circle(radius)
        turtle.penup()
        turtle.goto(centerX, centerY)
        turtle.right((countOG / 2) - 180)
        count -= 1

drawCirclePattern()

1 个答案:

答案 0 :(得分:2)

您正在调用不带参数的drawCirclePattern(),但应为5。

例如:drawCirclePattern(100, 200, 50, 100, 10)