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()
Recent Entries
- Compute Goes to Coding April 29, 2026
- Green Against Red April 29, 2026
- Cloying Was the Brief April 29, 2026