假设我有一个看起来像这样的电子邮件:蟒蛇解析text/plain的电子邮件
From hostname Tue Jun 15 21:43:30 2010
Received: (qmail 8580 invoked from network); 15 Jun 2010 21:43:22 -0400
Received: from mail-fx0-f44.google.com (209.85.161.44)
by ip-73-187-35-131.ip.secureserver.net with SMTP; 15 Jun 2010 21:43:22 -0400
Received: by fxm19 with SMTP id 19so170709fxm.3
for <[email protected]>; Tue, 15 Jun 2010 18:47:33 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.103.84.1 with SMTP id m1mr2774225mul.26.1276652853684; Tue, 15
Jun 2010 18:47:33 -0700 (PDT)
Received: by 10.123.143.4 with HTTP; Tue, 15 Jun 2010 18:47:33 -0700 (PDT)
Date: Tue, 15 Jun 2010 20:47:33 -0500
Message-ID: <[email protected]>
Subject: TEST 12
From: Full Name <[email protected]>
To: [email protected]
Content-Type: text/plain; charset=ISO-8859-1
ONE
TWO
THREE
我知道我可以使用msg = email.message_from_string(str)
和msg['To']
得到[email protected]
,但如何鉴别“一二三“ 在底部?奖励!如何识别顶部的所有“已收到:”k/v对?当我尝试:
msg['Received']
我只得到第一个。我如何获得第二个?
upvoted用于教学如何使用help()和dir(),这是我在其他语言中使用的令人难以置信的有用函数。 –