TypeError: int does not support the buffer in

2024-10-03 21:35:51 发布

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

我想在把变量转换成整数后给它赋值。我的代码:

timStamp = int(time.time()) // 30

但我得到了以下错误:

^{pr2}$

我也试过:

timStamp = time.time() // 30

这次我得到了:

TypeError: 'float' does not support the buffer interface

我已经在谷歌上搜索过了,但是我没有找到我想要的答案。 N: B:我正在使用Python3,我的完整源代码如下所示 http://paste.ubuntu.com/10584501/


Tags: the代码supporttimebuffer错误not整数
1条回答
网友
1楼 · 发布于 2024-10-03 21:35:51

您应该查看完整的回溯,看看错误发生在哪里。在这种情况下,代码产生

/tmp/test2.py in get_totp(secret)
     41     #timStamp = int (time.time() // 60)
     42     timStamp = int(time.time()) // 60
 -> 43     return get_hotp(secret, base64.b16encode(timStamp))
TypeError: 'int' does not support the buffer interface

所以问题是base64.b16encode需要一个字节字符串,而被赋予int或float。在

但是,我可以理解这种混乱,因为这个异常比您提供的行晚了一行。在

相关问题 更多 >