以10为基数的int()的tracker无效文本:

2024-07-05 11:06:14 发布

您现在位置:Python中文网/ 问答频道 /正文

好吧,我正试图在追踪器中获取人员和时间戳,但我一直得到这个错误:

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

Tags: pyformatforbasebot错误withago
1条回答
网友
1楼 · 发布于 2024-07-05 11:06:14
 if int(t) <= time.time()

不要对不表示整数的字符串调用int。如果字符串应该表示一个有效的整数,则输入有问题。如果允许字符串有一个小数部分,就像您所展示的输入一样,那么不要使用intfloat可能是合适的。在

相关问题 更多 >