1. 程式人生 > >python獲取當前文件路徑以及父文件路徑

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

image 成功 pytho python img 技術 lin lai tina

技術分享

#當前文件的路徑

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+"..") ##【by tina】 獲取父路徑和切換到新的父路徑下的其他目錄再連接其他目錄下的文件,實踐成功

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