在路径中创建缺少的目录

Aar*_*ken 5 python

有一个干净的方式来采取这样的道路:

/foo/bar/faz/baz/
Run Code Online (Sandbox Code Playgroud)

在哪里foobar存在,但是fazbaz不,并创造创造faz,baz而离开foobar孤独?(当然,这应该适用于某种类似的exists/exists/exists/doesnt_exist/doesnt_exit/doesnt_exist/doesnt_exist东西(非存在者/存在者的数量是可变的).

谢谢!

Joc*_*zel 8

os.makedirs 就是这么做的.