import json #for i in range(800): f1=open('.\\'+str(0)+'.txt', "r") data1 = f1.read() dic_str2 = json.loads(str(data1).replace("'", "\"")) for i in range(1,50): f=open('.\\'+str(i)+'.txt', "r") data2 = f.read() print(i) dic_str1=json.loads(str(data2).replace("'", "\"")) f.close dic_str2["icons"].extend(dic_str1["icons"]) f2=open('.\\1111111111111111111.txt', "a+") f2.write(str(dic_str2)) f2.close f1.close
标签:f1,f2,python,合并,dic,json,str,close From: https://www.cnblogs.com/GKLBB/p/17368652.html