【发布时间】:2014-11-23 21:47:56
【问题描述】:
由于某种原因,一段时间后我的代码出现了问题,
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 替换为 1 或 2 可以。为什么?
【问题讨论】:
-
我刚刚注意到代码有点自引用!
标签: python-2.7 floating-point overflowexception