Today want to write a message parsing file, read a piece of code, the source code is roughly as follows:
import sys, emailmailfile = open ('./ ReceivedHeader.txt ', ' R ') #mail载入并存入内存并解析它 #msg = email.message_from_file (Sys.stdin) msg = Email.message_from_file (mailfile) #print "Msg.items () function:\n" #print msg.items () #print "///// "print " *** headers in message: "#循环输出键和值for header, value in msg.items (): print header+ ":" print " "+ valueif msg.is_multipart (): print " this program Cannot handle mime multipart messages; exiting. " sys.exit (1) print "-" *78if ' subject ' in msg: print "Subject:" , msg[' Subject '] print "-" *78print " Message body: "Printprint msg.get_payload ()
is still a very simple and practical example, but is_multipart this function is not clear, to the official web-based review, given the following explanations:
Is_multipart () return True if the message ' s payload is a list of Sub-message objects, otherwise return False. When Is_multipart () returns FALSE, the payload should is a string object.
I xx ...., God Horse is a sub-mail ah, have not heard, and then after the search to understand that the so-called "sub-mail" is "spam", said the good euphemism, it is fluent, Is_multipart () is used to determine whether it is spam, if it is junk e-mail returns True, Otherwise, false is returned.
The matter is done, search the sub-mail, found a tall man's answer, reproduced under, happy, haha.
What is a sub-mail? Scam e-mail: It means unlucky her family are dead, he is also old, and have cancer, but her husband left him a legacy, and unlucky she on the internet magically got your e-mail address, she thought you must be God's good child, so want to give you the estate to deal with. That's basically what it means. At the peak of my time, I received one day. The Old high.
This article is from the "26-year-old" blog, please be sure to keep this source http://dbbruce.blog.51cto.com/2061658/1573857
The python--on the station is a bad sub-message.