Possible duplicate:How to calculate the relative path between two directories?
I need to calculate the relative path from one directory to another (i.e. I set the path relative to the working directory and want to calculate the corresponding relative path from any parent / subdir). What is a good way to do this in Python? I could not find much on this subject.
Thanks!
You should take a look at: os.path.relpath
os.path.relpath
os.path.relpath () does this for you and is available in Python 2.6 and later.
You can set the relative path using os.path.dirname ( file )
os.path.join (os.path.dirname ( file ), "filename")
Source: https://habr.com/ru/post/904329/More articles:PHP Get URL parameter and its value - arraysCodeigniter $ this-> db-> affected_rows () always returns 1 - codeigniterDetermine when a video has finished buffering - scriptingHide Preset Master Data - CocoaCreate a link that will add vCard directly to your address book - mobileWhat kind of visual studio is right for me? - c #java.text.ParseException: Unbeatable date: yyyy-MM-dd HH: mm: ss.SSSSSS - javaWhat is the best way to read the code of an already defined function (especially from the context of the system)? - wolfram-mathematicaSelect text to copy Android EditText - androidOptions to collapse YAML when viewing? - editorAll Articles