尽管我给了我一个整数,但我却收到了“ TypeError:期望的整数参数,浮点数”

时间:2019-11-03 20:07:08

标签: python

运行代码时,显示以下错误代码:{ "gameactivity": [ {"text": "ExampleBot is online", "value": "1"}, {"text": "ExampleBot - !help", "value": "2"}, {"text": "https://example.de", "value": "3"} ] }

我相信我给出的是整数,而不是浮点数。

我尝试将6个移动到支架内的不同位置,将6个完全删除,并使用6.0而不是6无效。

TypeError: integer argument expected, got float
pygame.draw.circle(screen, red,[x,y],6)

2 个答案:

答案 0 :(得分:1)

您可以将方括号中的值显式分配给参数。这可以帮助您进一步缩小错误范围。

例如

pygame.draw.circle(surface=screen, color=red, center=[x,y], radius=6)

请注意,这可能not be true for all python functions and modules

例如,Color接受int or tuple(int, int, int, [int]))。您可能正在向该参数传递浮点数。

答案 1 :(得分:1)

产生错误的参数不是6。也许是red?根据文档,这可以是Color枚举的实例,也可以是int的实例,我看不到您将其设置为什么。