Synopsis: How do I read a file in Python? why must it be done this way?
My problem is that I get the following error:
Traceback (most recent call last):
File "C:\Users\Terminal\Desktop\wkspc\filetesting.py", line 1, in <module>
testFile=open("test.txt")
FileNotFoundError: [Errno 2] No such file or directory: 'test.txt'
Which originates from the following code: (that is the entire '.py' file)
testFile=open("test.txt")
print(testFile.read())
"test.txt" is in the same folder as my program. I'm new to Python and do not understand why I am getting file location errors. I'd like to know the fix and why the fix has to be done that way.
I have tried using the absolute path to the file, "C:\Users\Terminal\Desktop\wkspc\test.txt"
Other details:
"Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32"
Windows 7, 32 Bit