import json with open("D:\store.txt", "r", encoding="utf-8") as f: data = json.loads(f.read()) print(len(data)) dataDict = {} for item in data: tempList = [] tempList.append(item['companyCode']) tempList.append(item['itemNo']) tempList.append(item['lotNumber']) if item['qualityStatus'] == '合格': tempList.append('Y') else: tempList.append('N') dataKey = '-'.join(tempList) value = item['quantity'] flag = True for key in dataDict: if key == dataKey: value = value + dataDict[dataKey] flag = False if flag: dataDict[dataKey] = value print(json.dumps(dataDict))
测试脚本1
最新推荐文章于 2023-04-10 14:18:23 发布