我写的代码如下:
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,程序运行成功
以上就是分析使用python的open函数时报No Such File or DIr的错误原因的详细内容,更多请关注php中文网其它相关文章!
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号