Create new folders within multiple existing folders with python

心不动则不痛 提交于 2019-12-13 07:48:31

问题


I am looking for a way to create new folders within multiple existing folders. For example I have folders a,b,c.. etc and I want to create a new folder inside each of these existing folders and name the new folders a1,b1,c1,.. etc. using a python script.


回答1:


Try looping through your list of folders rather than passing in the list. It is not the cleanest method out there but you can do something like:

parents = [p1, p2, p3]
childern = [c1, c2, c3]

for p in parents:
   for c in children:
      os.mkdir(os.path.join(p,c))


来源:https://stackoverflow.com/questions/14506864/create-new-folders-within-multiple-existing-folders-with-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!