Accessing JSON elements

前端 未结 5 1567
我寻月下人不归
我寻月下人不归 2020-11-30 23:19

I am getting the weather information from a URL.

weather = urllib2.urlopen(\'url\')
wjson = weather.read()

and what I am getting is:

5条回答
  •  失恋的感觉
    2020-11-30 23:59

    Another alternative way using get method with requests:

    import requests
    wjdata = requests.get('url').json()
    print wjdata.get('data').get('current_condition')[0].get('temp_C')
    

提交回复
热议问题