OS 创建多个文件夹

import requests
import os
import json
url='https://pvp.qq.com/web201605/js/herolist.json'
html=requests.get(url)
html_json=html.json()

B=list(map(lambda x:x['ename'],html_json))
N=list(map(lambda x:x['cname'],html_json))
#N=html_json[0]['cname']
#P=html_json[0]['']
#print(B,N)

def MKdir(name):
   C='F:/WZRY/'#盘符   当不输入盘符是默认在当前文件保存位置创建
   name=str(C)+str(name)+'/'
   da=os.path.exists(name)
   if not da:
      os.makedirs(name)
      print(str(name)+"创建成功!")
      return str(name)
   else:
      print("已存在,未创建!")
      return False
#name=MKdir(N)
for x in N:
   #root=MKdir(x)   
   print(x)#创建文件夹
   #for i in B:
    #   print(i)     
       #getimg(i,i,root)

#root='F:/WZRY/'

猜你喜欢

转载自www.cnblogs.com/zeng-qh/p/9932441.html