[英]python email subject \r\n
我在使用imaplib从我的邮箱中获取主题的脚本遇到麻烦。
这是我的脚本:
for mail in response[0].split():
typ, response = imap.fetch(mail, '(RFC822)')
for response_part in response:
if isinstance(response_part, tuple):
msg = email.message_from_string(response_part[1])
for header in [ 'subject']:
print msg["subject"]
但是我得到这个输出:
[astreinte] [2015.06.09 07:36:04] blurp : TIMESTAMP ALERT
Disaster is PROBLEM
我的问题是“ TIMESTAMP ALERT”之后的EndOfLine,如果我得到msg.items(),我可以查看:
('Subject', '[astreinte] [2015.06.09 07:36:04] ankdo2ga22 : DOFUS TIMESTAMP ALERT\r\n Disaster is PROBLEM')
所以,我不明白为什么\\ r \\ n存在? 它是否存在于元数据中。 但是在zabbix发送消息时未添加。 我使用office365。
非常感谢您的帮助。
无耻的插件:尝试使用我的库: https : //pypi.python.org/pypi/O365
如果您使用的是Office 365,它将使您的生活变得更加简单。
在回答您为什么存在\\ r \\ n的问题时,这是因为Office365基于Windows。 Windows由于遗留原因而使用\\ r \\ n作为换行符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.