Skip to content

Instantly share code, notes, and snippets.

@tdhopper
Created October 16, 2014 12:51
Show Gist options
  • Save tdhopper/2a36a89880d3257c7b67 to your computer and use it in GitHub Desktop.
Save tdhopper/2a36a89880d3257c7b67 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/python3
zip_code = '27560'
api_url = 'http://5dayweather.org/api.php?city=%s' % zip_code
from urllib.request import urlopen
import json
response = urlopen(api_url).read()
d = json.loads(response.decode('utf8'))
f = d['data']['temperature']
c = (float(f) - 32) * 5.0 / 9.0
print("%s°F (%.0f°C)" % (f, c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment