首页 > 解决方案 > TypeError:无法将 int 连接到字节

问题描述

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

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

如何解决这个问题?

标签: pythonimaplib

解决方案


我有同样的问题,我通过用str(uid)替换uid解决了它

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

再见


推荐阅读