How to get absolute path of a pathlib.Path object?
问题 Making a path object with pathlib module like: p = pathlib.Path('file.txt') The p object will point to some file in the filesystem, since I can do for example p.read_text() . How can I get the absolute path of the p object in a string? Appears that I can use for example os.path.abspath(p) to get the absolute path, but it awkward to use an os.path method, since I assume that pathlib should be a replacement for os.path . 回答1: You're looking for the method .absolute , if my understanding is