标签:python json
只支持列表、元组、字典
序列化
>>> import json >>> >>> f = open("user_acc.txt","w") >>> >>> info = { ... "alex":"123", ... "jack":"4444" ... } >>> >>> f.write(json.dumps(info)) 31 >>> >>> f.close() >>> >>> f = open("user_acc.txt","r") >>> data_from_atm = json.loads(f.read()) >>> print(type(data_from_atm)) <class ‘dict‘> >>> print(data_from_atm) {‘jack‘: ‘4444‘, ‘alex‘: ‘123‘} >>> f.close()
本文出自 “AMY” 博客,请务必保留此出处http://amy2015.blog.51cto.com/11407620/1770272
标签:python json
原文地址:http://amy2015.blog.51cto.com/11407620/1770272