我尝试编码utf-8和cp 1252,但有类似的输出
出于说明目的,file1.json = file2.json
[{"subject":"Math","operation":[{"sign":"÷"},{"sign":"+"}]}]
字符串
Python代码
json_files = ["file1.json", "file2.json"]
def merge_JsonFiles(json_files):
merge_jsonFile = 'merged.json'
result = list()
for f1 in json_files:
# with open(f1, 'r', encoding='cp1252') as infile:
# with open(f1, 'r', encoding='utf-8') as infile:
with open(f1, 'r') as infile:
result.extend(json.load(infile))
with open(merge_jsonFile, 'w') as output_file:
json.dump(result, output_file)
merge_JsonFiles(json_files)
型
1条答案
按热度按时间ssm49v7z1#
像这样试试
字符串