首页 > 编程 > Python > 正文

关于使用python的open函数出现No Such file or dir的错误

2019-11-10 17:14:18
字体:
来源:转载
供稿:网友

我写的代码如下:

1234567def createFileWithFileName(localPathParam,fileName):     totalPath=local_url+'//'+fileName     if not os.path.exists(totalPath):        PRint totalPath         file=open(totalPath,'w+'        file.close()         return totalPath 

起初时local_url使用的是绝对路径:F:程序名/imgs

但是了程序一直报No such file or dir的错,后来发现只要换为相对路径即可,

../imgs,程序运行成功


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表