您好,欢迎来到步遥情感网。
搜索
您的当前位置:首页分析使用python的open函数时报NoSuchFileorDIr的错误原因

分析使用python的open函数时报NoSuchFileorDIr的错误原因

来源:步遥情感网


我写的代码如下:

def 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,程序运行成功

Copyright © 2019- obuygou.com 版权所有 赣ICP备2024042798号-5

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务