假设我有一个以下文件:
{"id":"3234", "brand": "xyz", "binary":"fdsjl2j3jrl90i0ife"}
{"id":"4332", "brand": "abc", "binary":"hshgfdgfdsl90i0fsf"}
{"id":"2542", "brand": "wtr", "binary":"gfdgf22332l90i0ife"}
{"id":"9922", "brand": "kjl", "binary":"fdsjl23gssdsfwe223"}
当我运行以下功能时:
import json
filename = 'udata'
filename2 = 'odata'
#initialize list
records = []
#add records from the file to the list
with open(filename) as f:
for line in f:
print(json.loads(line))
记录使用单引号返回数据('')而非""
{'id': '2542', 'brand': 'wtr', 'binary': 'gfdgf22332l90i0ife'}
{'id': '3234', 'brand': 'xyz', 'binary': 'fdsjl2j3jrl90i0ife'}
{'id': '4332', 'brand': 'abc', 'binary': 'hshgfdgfdsl90i0fsf'}
{'id': '9922', 'brand': 'kjl', 'binary': 'fdsjl23gssdsfwe223'}
通缉输出:
{"id":"3234", "brand": "xyz", "binary":"fdsjl2j3jrl90i0ife"}
{"id":"4332", "brand": "abc", "binary":"hshgfdgfdsl90i0fsf"}
{"id":"2542", "brand": "wtr", "binary":"gfdgf22332l90i0ife"}
{"id":"9922", "brand": "kjl", "binary":"fdsjl23gssdsfwe223"}
答案 0 :(得分:0)
这真的不是问题。他们的意思完全相同。