How-to: How to get an absolute file path in Python #fix #computers #answer
How-to: How to get an absolute file path in Python #fix #computers #answer
How to get an absolute file path in Python
Given a path such as "mydir/myfile.txt", how do I find the absolute filepath relative to the current working directory in Python? E.g. on Windows, I might end up with:
"C:/example/cwd/mydir/myfile.txt"
Answer [by sherbang]: How to get an absolute file path in Python
>>> import os >>> os.path.abspath("mydir/myfile.txt")
Answer [by Will Harris]: How to…
View On WordPress











