我有这段代码:
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