json读写
import json l = [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)