string.find does not work in file

Curly Joe woooee at yahoo.com
Tue Jun 17 15:34:34 EDT 2003


I've had similiar, but not he same type of things
happen, and it was several versions ago.  It seems to
work correctly if you specifically declare a variable
name for the data, as in:
data = f.readlines()
for l in data:
etc.

You can also try a variation on find, although it
shouldn't matter,
int_result = l.find( '"\n' )

We know that there is a "\n" because that's the break
point for readlines, so it has to be the '"' if you
are gettin more than one line read.  If this doesn't
work, then post what you do get as output.  Also, I
assume that the 3 quotes in '"\n' is intentional.
 
> --- In python-list at yahoogroups.com, Wolfram Strau=DF
> <str at i...> wrote:
> > Hi,
> > I have a problem to run the following lines in a
> file.
> > >
> > import string
> > f =3D open('in.txt')
> > for l in f.readlines():
> > 	print string.find(l, '"\n')


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com





More information about the Python-list mailing list