我想使用
使用
如何在不包括文件名的情况下获取绝对路径?
pathlib
替换 file_location = os.path.abspath(os.path.dirname(__file__))
来获取文件的绝对路径而不包括文件名。
使用
directorypath = pathlib.Path(__file__).resolve()
可以获取带有文件名的绝对路径。
如何在不包括文件名的情况下获取绝对路径?