我正在尝试使用重音解码电子邮件信息,但我收到错误,我做错了什么?刚刚添加完整的追溯。
import gmail
import unicodedata
g = gmail.login('mail@gmail.com', 'myPass')
messagesPaypal = g.inbox().mail(unread=True, sender="member@paypal.com")
messagesPaypal[0].fetch()
data = messagesPaypal[0].body[500:900]
#print data
print data.decode('unicode-escape')
#ERROR:
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
PS C:\Users\admin> python "D:\\automate\\gmailExtract.py"
Traceback (most recent call last):
File "D:\\automate\\gmailExtract.py", line 130, in <module>
print data.decode('unicode-escape')
File "C:\Python27\lib\encodings\cp850.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\x82' in position 106: character maps to <undefined>
PS C:\Users\admin>