xmanman

导航

 

首先先知道几个常用的,找系统路径的命令:

  

当前文件的所在路径:
os.path.abspath(__file__) # /app/zws/test2.py

当前文件的所在的父级路径:
os.path.abspath(os.path.abspath(__file__) + os.path.sep + '..' + os.path.sep + '..')

  

另外:

  
import os
# 外部主程序,所在的目录,注意主程序中调用的子程序中,使用getcwd时,两者的路径一直
pwd = os.getcwd()

  

posted on 2020-03-12 14:38  xmanman  阅读(576)  评论(0编辑  收藏  举报