1:获取本地代码文件全路径:
import os
ab_path=os.path.abspath(__file__)
2:获取此文件所在的目录(不包括)运行程序的代码文件名字,而到其上层目录
import os
ab_path=os.path.abspath(__file__)
father_dir=os.path.dirname(ab_path)
3:获取上层目录(所在目录的上一级目录)
import os
ab_path=os.path.abspath(__file__)
father_dir=os.path.dirname(ab_path)
os.path.abspath(os.path.join(father_dir, ".."))