I'm going through the "Learn python the hard way". It suggest running
python from the terminal and using the
read commands on a file.
I created the provided script and sample text file, and the script runs fine, no errors. But I cannot figure out how to open and read the file from within python.
I always get
ex15_sample.txt is not defined. I am running python in the terminal from within the same folder that the script and text file are saved in. Within the script I do not give a file path, and I cannot figure where I'm going wrong?
open(ex15_sample.txt) # no go open(filepath/ex15_sample.txt) # nope file = open(ex15_sample.txt) # nope open ex15_sample.txt # nope print ex15_sample.txt.read() # nope open(ex15_sample.txt, read) # nope.
I cannot figure this one out, can any provide any insight?