[Tutor] OS lib creating an directory using an absolute path.

mhysnm1964 at gmail.com mhysnm1964 at gmail.com
Sat Feb 6 05:33:26 EST 2021


All,

 

I am using the os library. If I have a directory structure with any missing
directory (folders), then the os.mkdir function fails as it cannot find the
filenamefilename. For example:

 

Current directory structure is:

 

C:\books  with nothing inside.

 

The path I am wanting to create is:

 

E:\books\a\anne rice

 

Yes, I could break the path and check each level of the directory. But I was
wondering if there was any other method to do this. As if you do this at
Windows 10 command line:

 

Mkdir E:\books\"a\anne rice"

 

The 'a' directory plus 'anne rice' is also created. 

 

I hope this makes sense. Python 3.8 under windows 10.

 

Sean 



More information about the Tutor mailing list