小玩意 文件夹创建

import os
r = os.path.dirname(__file__)
b = 'task'
os.mkdir(r+'/'+b)
a = ['bin','db','lib','config','log']
for i in a:
    os.mkdir(r+'/'+b+'/'+i)

  

嵌套文件夹创建
import os r = os.path.dirname(__file__) a = 'Blank' Blank= os.mkdir(r + '/' + a ) b = ['Client','Manage','Server'] Client = ['config','lib',] Manage = ['config','lib',] Server = ['bin','config','db','log','lib',] for i in b: if i == b[0]: os.mkdir(r +'/'+ a + '/' + i) for i1 in Client: os.mkdir(r +'/'+a+'/'+i+'/'+i1) elif i == b[1]: os.mkdir(r +'/'+ a + '/' + i) for i1 in Manage: os.mkdir(r +'/'+a+'/'+i+'/'+i1) elif i ==b[2]: os.mkdir(r +'/'+ a + '/' + i) for i1 in Server: os.mkdir(r +'/'+a+'/'+i+'/'+i1)

  

posted @ 2017-01-05 17:51  200ML  阅读(125)  评论(0编辑  收藏  举报