python 获取当前文件夹路径及父级目录的几种方法

获取当前文件夹路径及父级目录:

import os
current_dir = os.path.abspath(os.path.dirname(__file__))
print(current_dir) #F:\project\pritice current_dir1 = os.path.dirname(__file__)
print(current_dir1) #F:/project/pritice parent_path = os.path.dirname(current_dir1)
print(parent_path) #F:/project parent_path1 = os.path.dirname(parent_path)
print(parent_path1) #F:/ parent_path2 = os.path.dirname(current_dir)
print(parent_path2) #F:\project
上一篇:Microservice架构模


下一篇:在java程序当中怎么获取一个文件的路径