一段时间后由于某种原因,我的代码引发了
OverflowError: cannot convert float infinity to integer
. 我看不出它为什么会这样做,很少使用浮点数,也没有使用 inf,
def bugsInCode(begin):
bugs = begin
while bugs != 0:
print "%s bugs in the code, %s bugs\ntake one down patch it around, %s bugs in the code!" % (bugs, bugs, int(bugs * 1.5))
bugs = int(bugs * 1.5)
但是替换1.5
为 a1
或 a2
作品。为什么?