【发布时间】:2018-01-24 16:41:51
【问题描述】:
我有这个代码:
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
标签: python file numpy operating-system directory