Python获取当前目录路径和上一级目录路径(父级路径)

#coding=UTF-8
import os

# 当前路径
current_path = os.path.dirname(__file__)

# 上一级路径(父级路径)
parent_path = os.path.dirname(current_path)

print("当前路径:" + current_path)
print("上一级路径:" + parent_path)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章