Create missing directories on the way

Is there a clean way to do this?

/foo/bar/faz/baz/ 

where foo and bar exist, but faz and baz do not, and create create faz and baz , leaving only foo and bar ? (Of course, this should work for something like exists/exists/exists/doesnt_exist/doesnt_exit/doesnt_exist/doesnt_exist or whatever (the number of nonexistent / nouns is variable) too.

Thanks!

+4
source share
1 answer

os.makedirs does just that.

+7
source

Source: https://habr.com/ru/post/1334012/


All Articles