json读写

import jsonl = [1,2,abc,{name:bob,age:13}]print(json.dumps(l))d = dict(b=None,a=5,c=abc)print(json.dumps(d, separators=[,,:])) # 设置分隔符# 按key值排序print(json.dumps(d, sort_keys=True))l2 = json.loads({"b":"x","a":5,"c":"abc"})print(l2)with open(‘‘,wb) as f: json.dump(l,f)

 

json读写

相关文章