📌  相关文章
📜  AttributeError: 'str' object has no attribute 'decode' site:stackoverflow.com - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:15.708000             🧑  作者: Mango

代码示例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')