我有這樣的代碼:蟒蛇 - numpy的FileNotFoundError:[錯誤2]沒有這樣的文件或目錄
import os.path
import numpy as np
homedir=os.path.expanduser("~")
pathset=os.path.join(homedir,"\Documents\School Life Diary\settings.npy")
if not(os.path.exists(pathset)):
ds={"ORE_MAX_GIORNATA":5}
np.save(pathset, ds)
但錯誤,他給我的是:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Maicol\\Documents\\School Life Diary\\settings.npy'
我怎樣才能解決這個問題?該文件夾未創建...
感謝
嘗試使用'os.path.isfile' – Stack