Random

Find Temperature of a world city using weather api: openweathermap.org

# find temperature of a city using weather api 
import urllib2
import json
response = urllib2.urlopen('http://api.openweathermap.org/data/2.5/weather?q=London,uk')
html = response.read()
# print html
j = json.loads(html)
kelvin = j["main"]["temp_min"]
celsius = kelvin - 273
print celsius
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s