Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75977 > unrolled thread
| Started by | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| First post | 2014-08-10 11:28 +0100 |
| Last post | 2014-08-10 11:28 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: how to get the subject of email? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-10 11:28 +0100
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-08-10 11:28 +0100 |
| Subject | Re: how to get the subject of email? |
| Message-ID | <mailman.12813.1407666504.18130.python-list@python.org> |
On 10/08/2014 02:41, luofeiyu wrote:
> I am in python3.4
>
> typ, data = x.con.fetch(b'1', '(RFC822)') #get the first email
> text = data[0][1]
> message = email.message_from_string(text).get('subject')
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "D:\Python34\lib\email\__init__.py", line 40, in
> message_from_string
> return Parser(*args, **kws).parsestr(s)
> File "D:\Python34\lib\email\parser.py", line 70, in parsestr
> return self.parse(StringIO(text), headersonly=headersonly)
> TypeError: initial_value must be str or None, not bytes
>
> message = email.message_from_string(str(text)).get('subject')
> message # nothing displayed
Could the answer to your numerous questions be in the docs, in this case
https://docs.python.org/3/library/email.html ?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
Back to top | Article view | comp.lang.python
csiph-web