readline() - problem
ricaraoz at gmail.com
Wed Oct 3 01:11:46 CEST 2007
Paul Hankin wrote:
> On Oct 2, 12:25 pm, pi... at kolodziejczyk.waw.pl wrote:
>> I'm a new user of python, and have problem.
>> I have a plain ascii file:
>> I want to create a new file which contains only lines with '1' on 15th
>> I've tried this:
>> import string
>> for line in f:
>> s= f.readline()
>> if s=='1' :
>> Why it doesn't work ('s' contains ' ' )?
> You're iterating over the lines in f already, so no need to call
> for line in f:
> if line == '1':
> Paul Hankin
Be aware also that the 15th position in your line would be line.
More information about the Python-list