How do I determine the absolute path to a file?

Asked 2 years ago, Updated 2 years ago, 141 views

Given a relative path, such as "mydir/myfile.txt" "C:/example/cwd/mydir/myfile.txt" Like this How do I find the absolute path?

python path relative-path absolute-path

2022-09-22 16:10

1 Answers

The function that receives the path and returns the absolute path is os.path" in the os module.absppath(path).

import os
os.path.abspath("mydir/myfile.txt")


2022-09-22 16:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.