# coding:utf-8
import os


'''***获取当前目录***'''
print(os.getcwd())
print(os.path.abspath(os.path.dirname(__file__)))

'''***获取上级目录***'''
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(os.path.abspath(os.path.join(os.getcwd(), "../..")))

 

相关文章:

  • 2018-08-29
  • 2021-11-20
  • 2021-12-09
  • 2021-11-29
  • 2021-12-07
  • 2021-11-12
  • 2021-12-20
猜你喜欢
  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
  • 2021-10-18
  • 2021-11-27
  • 2021-11-27
  • 2021-11-30
相关资源
相似解决方案