标签:ar 文件 sp on c ad r bs python
cat t.jo
{ "name":"test", "type":"kkk", "ppp":{"parate":[1,2]} } 或者加个数组t2.jo: [ {"name":"test","type":"kkk","ppp":{"parate":[1,2]}}, {"name":"ppp"} ]
2.解析t.jo
import json In [61]: s=json.loads(‘{"name":"kkk","type":"ppp"}‘) In [62]: s[‘name‘] Out[62]: u‘kkk‘ -------------t.jo f=file(‘t.jo‘) s=json.load(file(f)) 或者 s=json.load(file("t.jo")) print s[‘name‘] print s[ppp][‘parate‘][0] --------------t2.jo In [97]: f=file(‘t2.jo‘).read() In [98]: t=json.JSONDecoder().decode(f) In [99]: print t[0][‘ppp‘]
标签:ar 文件 sp on c ad r bs python
原文地址:http://my.oschina.net/jk409/blog/317751