1.os.path.abspath(__file__) :指当前文件的绝对路径
2.os.path.dirname(os.path.abspath(__file__)):指当前文件的上一级目录

  

总结:获取当前绝对路径使用:os.path.abspath(__file__)

         获取当前文件的上一级路径使用:os.path.dirname

 

相关文章: