0
How do I read the relative file path that is in a different python file directory and then open that file?
For example:
For archive1 in the name_project/files/file1.txt directory and the python code in the name_project/srcfunction directory os.path.relpath me returns file1.txt as relative path and the open function generates an exception of
IOError.
Want to open a python file or read the file in another directory?
– Marlysson
Read file in another directory
– absentia
I’ve reread the question a few times and I couldn’t understand what was asked. If you know where the file is regarding your code, what exactly do you need to do? If your code is on
srcfuncão, just open the filearquivos/arquivo1.txt.– Woss
It’s just an example. I just wanted to say that the file and the code are in different directories
– absentia
How are you trying to do ? You can put the code ?
– Felipe