How do I determine the absolute path to a file?

Asked 1 years ago, Updated 1 years ago, 124 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.