1.os.path.abspath(__file__) :指当前文件的绝对路径
2.os.path.dirname(os.path.abspath(__file__)):指当前文件的上一级目录
总结:获取当前绝对路径使用:os.path.abspath(__file__)
获取当前文件的上一级路径使用:os.path.dirname
python 浅谈os.path路径问题
原文:https://www.cnblogs.com/fh-fendou/p/9959247.html