TypeError:无法将int转换为字节

时间:2019-10-18 18:13:20

标签: python imaplib

运行此代码以阅读电子邮件:

if uid > uid_max:
            result, data = server.uid('fetch', uid, '(RFC822)')  # fetch entire message
            msg = email.message_from_string(data[0][1])

我收到此错误:

TypeError: can't concat int to bytes

该如何解决?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我将 uid 替换为 str(uid)

result, data = server.uid('fetch', str(uid), '(RFC822)')

再见