Sat*_*tor 7 directory path python-3.x pathlib
我想替换file_location = os.path.abspath(os.path.dirname(__file__)) 为pathlib来获取没有文件名的文件的绝对路径 使用 using directorypath = pathlib.Path(__file__).resolve() 给我绝对路径+文件名 我怎样才能获得没有文件名的绝对路径?
file_location = os.path.abspath(os.path.dirname(__file__))
pathlib
directorypath = pathlib.Path(__file__).resolve()
小智 11
您可以使用“.parent”: directorypath = pathlib.Path(__file__).resolve().parent Path.parent
directorypath = pathlib.Path(__file__).resolve().parent
归档时间:
5 年,5 月 前
查看次数:
5747 次
最近记录: