python 浅谈os.path路径问题

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

  

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

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

 

猜你喜欢

转载自www.cnblogs.com/fh-fendou/p/9959247.html
今日推荐