[Tutor] striping whitespace from files (original) (raw)
kumar s ps_python at yahoo.com
Sat Jul 10 13:07:50 CEST 2004
- Previous message: [Tutor] Re: help with setting Python Path under WinMe
- Next message: [Tutor] striping whitespace from files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi all , I am learning programming using python. I have a question about striping white spaces from a file. my logic is that each element of the list [i] iterates and the whitespace it encounters is stripped by strip function. I do not know where I am going wrong. Is my logic incorrect or it is the way that my syntax is wrong. Can any one please help. Thank you.
SP
f1 = open("citrate.txt",'r') f2 = f1.read() from string import strip, split f2 = f1.readlines() list = split(f2,'\n') for i in fstrings: f1strings = string.split([i]) print f1strings
Traceback (most recent call last): File "<pyshell#86>", line 2, in -toplevel- f1strings = string.split([i]) File "C:\Python23\lib\string.py", line 121, in split return s.split(sep, maxsplit) AttributeError: 'list' object has no attribute 'split'
Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
- Previous message: [Tutor] Re: help with setting Python Path under WinMe
- Next message: [Tutor] striping whitespace from files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]