所以我有一些代码:
self.nextY = int(self.y + self.aY * 0,7071 - (9.98 * 0.1 * 0.1)/2)
这是追溯:
Traceback (most recent call last):
File "C:\Users\CrazyDude\workspace\flappy-bird-bot\src\main.py", line 16, in <module>
bird.get_position(image)
File "C:\Users\CrazyDude\workspace\flappy-bird-bot\src\flappy.py", line 31, in get_position
self.nextY = int(self.y + self.aY * 0,7071 - (9.98 * 0.1 * 0.1)/2)
TypeError: integer argument expected, got float
如果我将变量更改为int,它怎么能期望int?
答案 0 :(得分:3)
代码将两个参数传递给int
函数。 (如果有两个参数,则第二个参数被视为base
,它应该是整数。)
>>> int('10', 2.1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: integer argument expected, got float
>>> int('10', 2)
2
也许您的意思是0.7071
而不是0,7071
?