[Tutor] Reading from a file
Israel Evans
israel@lith.com
Fri, 17 Aug 2001 11:21:05 -0700
this may not be the best way to do it but it seems to work... I'm rather new
to this to.
>>> line = """"CVR",1,2"""
>>> info = line.split(',')
>>> info
['"CVR"', '1', '2']
>>> info.remove(info[len(info)-1])
>>> info
['"CVR"', '1']
I'm just removing the last item in the list. The /012 is probably some sort
of line ending like \n? I'm guessing.
-----Original Message-----
From: robert frank brenart [mailto:rfbrenar@cs.uchicago.edu]
Sent: Friday, August 17, 2001 11:10 AM
To: tutor@python.org
Subject: [Tutor] Reading from a file
I'm reading in from a file line by line and splitting up the information
based on commas... however, the last item in every line has an /012
attached to it... i.e.
"CVR",1,2
comes out as
['"CVR"', '7', '3\012']
Just wondering how I can get rid of that \012.
-Rob
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor