Python中使用Json

首先从http://pypi.python.org/pypi/python-json下载python-json, 然后安装。

解压zip 然后把json.py minjson.py 拷到 /usr/lib/python2.5/下面就行了。

怎样使用请看:http://docs.python.org/library/json.html

或者如下简单例子:

 

import json

 

s = '[{"name":"niaochao","point":{"lat":"39.990","lng":"116.397"},"desc":"aoyunhuizhuchangdi"},{"name":"beidapingpangqiuguan","point":{"lat":"39.988","lng":"116.315"},"desc":"pingpangqiubisaichangdi"},{"name":"beijinggongrentiyuchang","point":{"lat":"39.930","lng":"116.446"},"desc":"zuqiubisaichangdi"}]'

 

locations = json.read(s)

print str(len(locations))

for location in locations:

    print location["name"]

    print location["point"]["lat"]

 

 

你可能感兴趣的:(html,json,python)