Accessing JSON elements

前端 未结 5 1573
我寻月下人不归
我寻月下人不归 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-12-01 00:00

    Here's an alternative solution using requests:

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

提交回复
热议问题