python 收取邮件都是乱码。 python发送邮件,网页接收正常,Foxmail附件乱码
python \u53d1\u90ae\u4ef6\u4e71\u7801\u7684\u51e0\u79cd\u89e3\u51b3\u65b9\u6cd5\u6253\u5f00python\u7684Lib\u6587\u4ef6\u5939\u4e0b\u7684 mimetypes.py \u6587\u4ef6\uff0c\u627e\u5230\u5927\u6982256\u884c\u7684\u2018default_encoding = sys.getdefaultencoding()\u2019\u3002\u5728\u8fd9\u884c\u524d\u9762\u6dfb\u52a0\u4e09\u884c\uff0c\u5e76\u4e14\u6ce8\u91ca4\u884c\u4ee3\u7801 #try: # ctype = ctype.encode(default_encoding) # omit in 3.x! #except UnicodeEncodeError: # pass else: yield ctype i += 1 if sys.getdefaultencoding() != 'gbk': reload(sys) sys.setdefaultencoding('gbk') default_encoding = sys.getdefaultencoding()
\u5e94\u8be5\u662f\u7f16\u7801\u7684\u95ee\u9898\u2026\u2026\u8bf4\u4e0d\u5b9a\u53d1\u9001\u82f1\u6587\u6216\u8005\u6570\u5b57\u7684\u80fd\u591f\u6b63\u5e38\u5462\uff1f
\u597d\u5427\uff0c\u5176\u5b9e\u6211\u4e5f\u4e0d\u592a\u6e05\u695a
\u4e0d\u8fc7\u6211\u5173\u6ce8\u7684\u4e0d\u662f\u8fd9\u4e2a\uff0c\u800c\u662f\u653e\u5728\u6587\u4ef6\u5939\u4e0b\u7684\u65b9\u6cd5\u592a\u86cb\u75bc\u4e86\u3002
\u5f04\u4e2a\u62d6\u52a8\u7684\u5427\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u653e\u5728%userprofile%\AppData\Roaming\Microsoft\Windows\SendTo\u6587\u4ef6\u5939\u4e0b\uff0c\u76f4\u63a5\u201c\u53d1\u9001\u5230\u201d\u4e86\uff0cgetfile\u7528\u4e8e\u63a5\u6536\u6587\u4ef6\u8def\u5f84\u3002
try:
#\u5f97\u5230\u62d6\u52a8\u7684\u6587\u4ef6\u8def\u5f84
getfile = sys.argv[1]except Exception, e:
#\u7528\u6b63\u5e38\u65b9\u5f0f\u6253\u5f00
getfile = raw_input('\u8f93\u5165\u5b8c\u6574\u8def\u5f84\u83b7\u53d6\u9644\u4ef6\uff08\u62d6\u52a8\u6587\u4ef6\u5230\u63a7\u5236\u53f0\u7a97\u53e3\uff09\uff1a')filename = os.path.basename(getfile) #\u4ece\u8def\u5f84\u83b7\u53d6\u6587\u4ef6\u540d
\u5bf9\u4e86\uff0c\u522b\u5fd8\u8bb0\u628a.py\u540e\u7f00\u6539\u6210.pyw\uff0c\u6d88\u9664\u9ed1\u8272\u7a97\u53e3\u2026\u2026
\u8fd8\u6709\u5f04\u4e2a
import ctypes#\u2026\u2026#\u7ed3\u675f\u540e\u5f39\u51fa\u63d0\u793a\u5bf9\u8bdd\u6846text = filename + '\n' + 'Successfully sent to ' + msg['to']ctypes.windll.user32.MessageBoxA(0, text, '', 0)#\u2026\u2026
\u6765\u5427\uff0c\u53ef\u52b2\u5730\u6298\u817e\u5427\u3002
不是乱码,是base64编码
看廖雪峰python里面的对pop3收取邮箱内容的解码方法把,很有用
扩展阅读:python手机版下载官方 ... python for beginners ... python 文化 示例 ... python网站 ... python for死循环 ... python random库 ... python运行暂停 继续 ... python serial库 ... python gui 哪个好 ...