好吧,我正试图在追踪器中获取人员和时间戳,但我一直得到这个错误:
invalid literal for int() with base 10: 1389584370.27156
这是导致错误的代码:
^{pr2}$错误发生在以下行:
t += "{} about {} ago".format(viewer, stamp.getTimeStamp(timest))
回溯来自timestamp2.py行:
Traceback (most recent call last): File "G:\Bots\Dragion Bot\Dragion Bot.Py", line 1159, in onMessage t += "{} about {} ago".format(viewer, stamp.getTimeStamp(timest)) File "G:\Bots\Dragion Bot\timestamp2.py", line 6, in getTimeStamp if int(t) <= time.time(): ValueError: invalid literal for int() with base 10: '1389584370.27156'
在url中是具有相同标记“viewer”和“timestamp”的字典,例如:
http://chtracker.info/index.py?output=json&x=page&y=mechabot
不要对不表示整数的字符串调用
int
。如果字符串应该表示一个有效的整数,则输入有问题。如果允许字符串有一个小数部分,就像您所展示的输入一样,那么不要使用int
。float
可能是合适的。在相关问题 更多 >
编程相关推荐