python - How to find the relative path between two directories? -


i find relative path between 2 directories on system.

example:

if have patha == <patha> , pathb == <patha>/dir1/dir2, relative path between them dir1/dir2.

how find in python? there tool use?

if pathb contained in patha, pathb.replace(patha, '') relative path, if pathb isn't contained in patha?

os.path.relpath(path1, path2) # that's it


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -