我有这样的代码:蟒蛇 - 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