Python3 获取绝对路径

import os
os.path.abspath(’.’) # 当前所处的文件夹的绝对路径,如/usr/local
Python3 获取绝对路径
os.path.abspath(’…’) # 当前所处的文件夹上一级文件夹的绝对路径
Python3 获取绝对路径
os.path.abspath(os.path.dirname(file)) # 当前文件所在绝对路径
Python3 获取绝对路径
os.path.abspath(os.path.dirname(os.path.dirname(file))) # 当前文件所在上级绝对路径
Python3 获取绝对路径
os.path.abspath(os.path.join(os.getcwd(), “…”)) # 当前文件所在上级绝对路径
Python3 获取绝对路径

os.path.abspath(os.path.join(os.getcwd(), “…/…”)) # 当前文件所在上上级绝对路径

Python3 获取绝对路径

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
猜你喜欢
  • 2021-05-28
  • 2021-11-30
  • 2021-11-27
  • 2022-01-10
  • 2021-09-04
  • 2022-02-15
  • 2022-12-23
相关资源
相似解决方案