【发布时间】:2019-03-13 19:48:32
【问题描述】:
我正在阅读 gmail 邮件 (using the code from accepted answer)
(retcode, messages) = conn.search(None, '(UNSEEN)')
if retcode == 'OK':
for num in messages[0].split(' '): # messages[0] is b'6' in my case.
它抛出,“TypeError:需要一个类似字节的对象,而不是'str'”。
但我可以清楚地看到它是一个字节对象b'6'
在 python shell 上也试过同样的错误。不知道这里出了什么问题。
>>> b'6'.split(' ')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
【问题讨论】:
标签: python split gmail-imap