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)

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