[英]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.