Garey's Blog–FreeBSD/PHP/GoLang

二月 26th, 2010

python使用json的方法

11,439 views, Python, by garey.

>>> import json
>>> userinfo = {‘name’: ‘garey’, ‘dob’: ’1983-01-01′, ‘gender’: ‘M’, ‘country’: ‘CN’, ‘access’: 0, ‘state’: 1, ‘last_login’: ’2010-02-25 18:00:00′}
>>> json_userinfo = json.write(userinfo)
>>> json_userinfo
‘{"name":"garey","dob":"1983-01-01","gender":"M","country":"CN","access":0,"state":1,"last_login":"2010-02-25 18:00:00"}’
>>> user = json.read(json_userinfo)
>>> user['name']
‘garey’

Back Top

发表评论