gpt4 book ai didi

python - 在路径中创建缺少的目录

转载 作者:太空狗 更新时间:2023-10-30 00:52:13 26 4
gpt4 key购买 nike

是否有一种干净的方式来采用这样的路径:

/foo/bar/faz/baz/

其中 foobar 存在,但是 fazbaz 不存在,并且创建创建 fazbaz 而单独留下 foobar ? (当然,这也适用于 exists/exists/exists/doesnt_exist/doesnt_exit/doesnt_exist/doesnt_exist 或其他任何东西(不存在/存在的数量是可变的)。

最佳答案

os.makedirs正是这样做的。

关于python - 在路径中创建缺少的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4580641/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com