文件:allpath_parameter.py
- # 获取当前目录路径
- # current_dir = os.getcwd() # 获取当前目录路径
- realpath00 = os.path.abspath(os.path.join(os.path.dirname(os.path.split(os.path.realpath(__file__))[0]), '.'))
- print(realpath00)
-
- # 获取当前目录的上级目录路径
- parent_dir = os.path.dirname(realpath00)
- print(parent_dir)
- # 获取当前脚本文件的绝对路径
- current_path = os.path.abspath(__file__)
- print(current_path)
-
- # 获取当前脚本文件所在的目录路径
- current_dir = os.path.dirname(current_path)
- print(current_dir)
-
- # 获取项目根目录
- project_dir = os.path.dirname(current_dir)
- print(project_dir)
运行: