If you run a script from /tmp/myfolder/myscript/, and want to access a resource in myfolder, how do you do that in python?
I did get the file path with
Python does understand
os.chdir(). I am not sure exactly what you are trying to do, but you can try:
import os os.chdir('..')
This will change your working directory to the one above the current one (just like
You can also use
.. for many operations that use paths. For example, if you want to open a file that is up one directory:
open('../myfile.txt'), etc. You may also find the answers to this question useful, depending on what your goal is.