So I was trying to learn the function open
which is apparently easy to use. I copied a really simple code from a website to just open and read a file called "test.txt" with some text on it. I tried it both ways, not specifying the path (since it's in the same folder) and calling the whole path. None worked (FileNotFoundError
). It's all in a server so that might be the problem but I'd still like a short explanation if that is the problem.
Go easy on the vocabulary please, I'm just taking the first steps.
On the image I tried to stack as much info as posible: link.
handle = open("test.txt")
data = handle.read()
print(data)
handle.close()
SOLUTION: I actually just removed the .txt from the text file. Now it's name is test and it is a text file and the code works. I previously moved the python file and text file from the server to the computer since a comment said it could be the problem, but after finding my solution i put it all back in the server and the program runs as well.