python獲取當前文件路徑以及父文件路徑

#當前文件的路徑
pwd = os.getcwd()
#當前文件的父路徑
father_path=os.path.abspath(os.path.dirname(pwd)+os.path.sep+".")
#當前文件的前兩級目錄
grader_father=os.path.abspath(os.path.dirname(pwd)+os.path.sep+"..")
相關文章
相關標籤/搜索