FileNotFoundError: [Errno 2] No such file or directory:'D:\\a\\b'

View files in the directory D:


 

 

 


Create a directory using the os module, the code is as follows:

= R & lt path " D: \ A \ B " 
isExists = os.path.exists (path)
 Print (isExists)
 IF  Not isExists:   # path does not exist, i.e., the file name does not exist 
    os.mkdir (path)
View Code 

Then ........... FileNotFoundError: [WinError 3] path system not specified. : 'D: \\ a \\ b'


 

 

 After a struggle, and finally found: D disk is simply not a directory, and create b directory under a directory, the system will error. So in the current directory, you can not create subdirectories and Sun directory. Correct wording is as follows;


 

= R & lt path " D: \ A " 
os.mkdir (path) 
path = R & lt " D: \ A \ B " 
isExists = os.path.exists (path)
 Print (isExists)
 IF  Not isExists:   # path does not exist, i.e., file name does not exist 
    os.mkdir (path)
View Code

This deposit is pure Xueyibujing question, write this blog post is just to remind myself to seriously study. There have problems do not panic, patience, look at the code, check out the information, will always find a solution.

Guess you like

Origin www.cnblogs.com/qihuang94/p/12380338.html