Extracting patterns after matching a regex

Dave Angel davea at ieee.org
Tue Sep 8 17:19:13 CEST 2009

Mart. wrote:
> <snip>
> I have been doing this to turn the email into a string
> email =ys.argv[1]
> f =open(email, 'r')
> s =str(f.readlines())
> so FTPHOST isn't the first element, it is just part of a larger
> string. When I turn the email into a string it looks like...
> 'FINISHED: 09/07/2009 08:42:31\r\n', '\r\n', 'MEDIATYPE: FtpPull\r\n',
> 'MEDIAFORMAT: FILEFORMAT\r\n', 'FTPHOST: e4ftl01u.ecs.nasa.gov\r\n',
> 'FTPDIR: /PullDir/0301872638CySfQB\r\n', 'Ftp Pull Download Links: \r
> \n', 'ftp://e4ftl01u.ecs.nasa.gov/PullDir/0301872638CySfQB\r\n', 'Down
> load ZIP file of packaged order:\r\n',
> <snip>

The mistake I see is trying to turn a list into a string, just so you 
can try to parse it back again.  Just write a loop that iterates through 
the list that readlines() returns.


More information about the Python-list mailing list