0
我是一個noob並使用Flanker解析郵件。 https://github.com/mailgun/flanker側面:MimePart不可迭代
我得到了一個Not Iterable錯誤,我似乎無法弄清楚。我已經閱讀了大量關於列表的頁面,但我無法實現它的工作。我希望我能得到一些幫助。
要運行以下代碼,您需要安裝Flanker,並將該文件另存爲「email」。 http://pastebin.com/ZS4q2kYN
我正在嘗試閱讀'attachmenttype'並根據響應進行操作。不能讓它工作。下面是測試代碼:
#!/usr/bin/python
#Open Email
from flanker import mime
with open ("email", mode="rb") as myfile:
message_string=myfile.read()
myfile.close()
#Read Email
msg = mime.from_string(message_string)
#read attachment type
attachmenttype = msg.parts[1]
print attachmenttype
#This errors for me: TypeError: argument of type 'MimePart' is not iterable
if attachmenttype:
if '(text/html)' in attachmenttype:
print "woohoo"
在此先感謝。
OMG THANK YOU!我昨天花了整整一天的時間,然後是星期五的大部分時間。哇...感謝您的快速回復 –
你能解釋爲什麼這不是一個字符串? –
這是一個有很多方法的對象。例如,text和html是這個類的獨立屬性,通過轉換爲字符串連接起來。 –