Reading a Simple Text File with Python
February 8, 2019
Here's a script to read the contents of a text file.
from sys import argv
script, filename = argv
#open the file and read contents
txt = open(filename)
print txt.read()
print "Read the file again?"
file_again = raw_input("> ")
txt_again = open(file_again)
print txt_again.read()
Related Entries
- Opening & Reading Files January 25, 2018
- Erasing and Writing to a Text File February 11, 2019
- Limiting File Size to Copy with Python February 27, 2018