izb izb - 1 year ago 121
Python Question

How to get an absolute file path in Python

Given a path such as

, how do I find the absolute filepath relative to the current working directory in Python? E.g. on Windows, I might end up with:


Answer Source
>>> import os
>>> os.path.abspath("mydir/myfile.txt")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download