import json
dic = {}
with open("train.txt", "r", encoding="utf8") as f:
merge_line = ""
for line in f:
line = line.strip()
merge_line += line
if len(merge_line) > 500:
dic[merge_line] = 1
merge_line = ""
with open("train.json", "w", encoding="utf8") as f:
json.dump(dic, f, ensure_ascii=False)
txt转json格式_Python
最新推荐文章于 2024-04-24 11:24:44 发布