python 浅谈os.path路径问题

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

  

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

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

 

posted @ 2018-11-14 17:40  那时的吻狠陶醉  阅读(754)  评论(0编辑  收藏  举报