how to read a text file in a directory in python
I've been working on a project with a lot of different files.
It would be a lot more organized if I could put files into directories based on their categories.
Unfortunately, when I try to read a file from a directory, it says "no such file or directory named ie.txt"
Does anyone know how to read a text file from a directory?
file = open("path/to/file.txt", "r") print(file.read())
And if your directory was:
path/ to/ file.txt
it would read perfectly.
Now, what if the files looked like this:
main.txt folder/ main.py
you can read
file = open("../main.txt") print(file.read())
Also super easy :D