Home > Backend Development > Python Tutorial > Analyze the reason for the error No Such File or DIr when using python's open function

Analyze the reason for the error No Such File or DIr when using python's open function

高洛峰
Release: 2017-03-15 14:39:01
Original
2629 people have browsed it

我写的代码如下:

def createFileWithFileName(localPathParam,fileName): 
    totalPath=local_url+'\\'+fileName 
    if not os.path.exists(totalPath):
        print totalPath 
        file=open(totalPath,'w+') 
        file.close() 
        return totalPath
Copy after login

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

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

../imgs,程序运行成功


The above is the detailed content of Analyze the reason for the error No Such File or DIr when using python's open function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template