Problems with io.
news at yebu.de
Wed Jul 2 15:38:16 CEST 2003
> some time ago I started to learn python, today i wanted make a very
> samll and simple program.
> file = open("test.txt", "r+")
> And it doesn't work...
Assuming file 'test.txt' exists, your program should work.
In your case, you can ommit the + in 'r+', or the 'r+' alltogether.
Also, choosing file as a variable is not a good idea, as it
hides the builtin function (which could have been used
as well instead of open()).
What your problem might be, is not seeing anything as
you do not fetch the result of fil.readlines().
So just do
lines = fil.readlines()
for line in lines:
> (sorry for such ask but it is anonyoning me why it doesn't work, if u
> don't reply i'll understand it)
More information about the Python-list