[Tutor] OS lib creating an directory using an absolute path.
Mats Wichmann
mats at wichmann.us
Sat Feb 6 05:49:37 EST 2021
On 2/6/21 3:33 AM, mhysnm1964 at gmail.com wrote:
> 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.
...
> 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.
use os.makedirs instead, or use the pathlib mkdir function with
appropriate argument
and would really suggest you not use directory names with spaces in
them, it will eventually bring you grief.
More information about the Tutor
mailing list