rook rook - 3 months ago 7
Python Question

Fixing '../../' paths in python

Is there an easy way in Python to resolve path operators like

..
? For instance is there a function call that will convert:
/../../test/../path
to
/path
?

Answer

You can use os.path.realpath() to get the canonical path. To get a normalised relative path, use os.path.normpath().

Comments