Adsense
Popular Posts
- jQuery autocomplete scroll bar for dropdown menu
- JavaScript Arrays and Associate Arrays
- mod_auth_cas.so error: undefined symbol: SSL_connect
- Design date and signature box in Latex
- Install APXS in Redhat Linux
- JavaScript, remove trailing insignificant zeros after toFixed function
- jQuery, toggle the display
- Difference between state and props in React
- Set Windows path command line
- super(props) in React
Tuesday, March 11, 2014
Json in Python 3.3
Example1.py: Json in Python 3.3
import json
data = [ { 'a':'A', 'b':(2, 4), 'c':3.0 } ]
data_string = json.dumps(data)
print(data_string)
data_load = json.loads(data_string)
print(data_load)
print(data_load[0]['a'])
return:
[{"a": "A", "b": [2, 4], "c": 3.0}]
[{'a': 'A', 'c': 3.0, 'b': [2, 4]}]
A
Reference:
http://pymotw.com/2/json/
#http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
#past 30days M4.5 earthquake
#http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.geojson
import urllib.request
import json
geourl = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.geojson"
response = urllib.request.urlopen(geourl)
content = response.read()
data = json.loads(content.decode("utf8"))
print(data)
print(data['type'])
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment