Questions tagged «imaplib»

7
'str'对象没有属性'decode'。Python 3错误?
这是我的代码: import imaplib from email.parser import HeaderParser conn = imaplib.IMAP4_SSL('imap.gmail.com') conn.login('example@gmail.com', 'password') conn.select() conn.search(None, 'ALL') data = conn.fetch('1', '(BODY[HEADER])') header_data = data[1][0][1].decode('utf-8') 此时,我收到错误消息 AttributeError: 'str' object has no attribute 'decode' Python 3不再具有解码了,对吗?我怎样才能解决这个问题? 另外,在: data = conn.fetch('1', '(BODY[HEADER])') 我只选择第一封电子邮件。如何全部选择?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.