[Tutor] Reading from a file
dman
dsh8290@rit.edu
Fri, 17 Aug 2001 14:57:55 -0400
On Fri, Aug 17, 2001 at 11:47:41AM -0700, Israel Evans wrote:
| That's what I was thinking..
|
| How about:
|
| >>> import re
| >>> pat = re.compile('\012')
| >>> line = """"CVR",1,2\012"""
| >>> info = re.sub(pat, '',line)
| >>> finalanswer = info.split(',')
| >>> finalanswer
| ['"CVR"', '1', '2']
It might be faster to do a string.replace() since your regex is just a
literal character. Since this character is considered as whitespace
the string.strip() works also.
-D