我是个笨蛋,用侧翼来分析邮件。 https://github.com/mailgun/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"
提前谢谢。你知道吗
attachmenttype
可以打印一个字符串,但它不是一个字符串,而是一个包含一些属性的结构。但是,既然你能打印出来,你就完成了一半。只需使用str
将其转换为字符串并进行比较。你知道吗像这样修复代码。我无法测试它,但我不知道它怎么会不起作用:
相关问题 更多 >
编程相关推荐