在python中找到文件位置

#当前文件的路径
pwd = os.getcwd()
#当前文件的父路径
father_path = os.path.abspath(os.path.dirname(pwd) + os.path.sep + "." )
#当前文件的前两级目录
grader_father = os.path.abspath(os.path.dirname(pwd) + os.path.sep + ".." )

猜你喜欢

转载自www.cnblogs.com/zhao-zhi-peng/p/11890319.html