1. 程式人生 > >python路徑相關小問題

python路徑相關小問題

1.getcwd無法再windows server上執行

使用os.path.dirname(__file__)獲取當前檔案目錄

2.SyntaxError: EOL while scanning string literal

windows路徑‘\’轉義問題,使用r轉義最後一個字元不能是‘\’;

dataPath =r "D:\exportMould\filePath/file\"錯誤,改成dataPath =r "D:\exportMould\filePath/file"+'\\'

3.python開啟windows共享資料夾檔案

dataPath =r "D:\exportMould\filePath/file"+'\\'