Byron
21 years ago
Hi Fred,
It looks like they have answered your questions. To reiterate in a
simple form, to open a file for reading, it is best to use something
like the following:
f = open("c:/test.txt", "r")
textlines = f.readlines() # Reads all lines into a list (array).
for line in textlines: # Prints each line that is read from the
text file.
print line
---
If you want to append (add additional information) to a text file, use
the following:
f = open("c:/test.txt", "a")
f.write("This is an appended line.\n")
f.close()
Hope this helps,
Byron
------------------------
It looks like they have answered your questions. To reiterate in a
simple form, to open a file for reading, it is best to use something
like the following:
f = open("c:/test.txt", "r")
textlines = f.readlines() # Reads all lines into a list (array).
for line in textlines: # Prints each line that is read from the
text file.
print line
---
If you want to append (add additional information) to a text file, use
the following:
f = open("c:/test.txt", "a")
f.write("This is an appended line.\n")
f.close()
Hope this helps,
Byron
------------------------
...