Storing lines from a text file
Fredrik Lundh
fredrik at pythonware.com
Sun Jan 29 18:08:06 EST 2006
bradfordh at gmail.com wrote:
> I am not sure how hard of a question is, but I do know that I need some
> help if you can give it. What I want to do is read the lines in a text
> file and store each line into a variable. I believe that I can use
> readlines() to read the individual lines, but how would I store each
> line into a variable for further analysis? Thanks for any and all
> suggestions.
any reason you cannot do the analysis on the list you get from readlines ?
if you insist on having the lines in individual variables, you can use straight-
forward sequence unpacking:
a, b, c, d, e = f.readlines()
</F>
More information about the Python-list
mailing list