[Python] 纯文本查看 复制代码#encoding=utf8
import json
import os
folder_1 = r".\参考1"
folder_2 = r".\参考2"
folder_3 = r".\完成目录"
all_mjsons = os.walk(folder_1)
for _, _, mjsons in all_mjsons:
for mjson in mjsons:
json_1 = os.path.join(folder_1, mjson)
json_2 = os.path.join(folder_2, mjson)
json_3 = os.path.join(folder_3, mjson)
if os.path.exists(json_2):
print("process:", mjson)
jf_1 = open(json_1, 'r')
jf_2 = open(json_2, 'r')
data_1 = json.loads(jf_1.read())
data_2 = json.loads(jf_2.read())
data_2[0][0]["count"] = data_1["Price"]
jf_3 = open(json_3, 'w')
json.dump(data_2, jf_3, indent=4)
else:
print(json_2, "file not found!")