当前位置: 代码迷 >> 综合 >> 获取当前的工作路径和上层的工作路径
  详细解决方案

获取当前的工作路径和上层的工作路径

热度:32   发布时间:2024-02-01 22:12:27.0

获取当前的工作路径和上层的工作路径 

import osprint '***获取当前目录***'
print os.getcwd()
print os.path.abspath(os.path.dirname(__file__))print '***获取上级目录***'
print os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
print os.path.abspath(os.path.dirname(os.getcwd()))
print os.path.abspath(os.path.join(os.getcwd(), ".."))print '***获取上上级目录***'
print os.path.abspath(os.path.join(os.getcwd(), "../.."))
  相关解决方案