0
我有一个愚蠢的问题,所以要求简单锻炼一点帮助。Python - ValueError:无效的文字为int()与基地10:'12 .449899598'
我得到: “ValueError异常:无效的字面INT()基数为10:'12 0.449899598' ”
- 当试图运行此代码:
def find_next_square(sq):
# Return the next square if sq is a square, -1 otherwise
from decimal import Decimal
import math
x = math.sqrt(sq)
y = str(x)
z = y.rstrip('0').rstrip('.') if '.' in y else y
for k in z:
if k != '.':
a = int(z)
return (a+1) * (a+1)
else:
return -1
四个样品的测试是积极的,只是这个错误使得不可能通过excercise .. 在此先感谢提示。