Hi,If the file you're reading is not too big, you can use file.readlines() which
I am a very beginner Python programmer with limited programming
experience overall.
I am trying to write a script that will search for the second and third
appearance of the symbol '@' in a file, will read a random line between
them, and write the line into a new file. So far I was only able to open
the file using 'open', but I am not sure how to proceed. I tried to read
it line by line using 'readline' but was not sure how to manipulate the
text the way I need to.
read all the files and returns its content as a list of lines.
Could anyone please give me |a basic guidance as for what functions maytext.find('@') will return the position of the first occurence of '@', or a
be useful for my purpose? (e.g how to search for a string '@' in a text?
how to identify its location?
negative value if not found.
how to choose a random number in a definedrandom.randrange(start, stop)
range?
how to read that line number from a text file? etc.)|if you read the file with readlines(), just lines[lineno]
you'll find more infos in the following sections:
http://docs.python.org/lib/bltin-file-objects.html
http://docs.python.org/lib/string-methods.html
http://docs.python.org/lib/module-random.html
--
CĂ©dric Lucantis