Make the Weather script more easily usable by those who use fahrenheit or a different measurement.

Jessi 2017-04-26 02:58:24 -07:00
parent 774a30af46
commit fa10db8735
1 changed files with 7 additions and 5 deletions

@ -146,15 +146,17 @@ For Gmail, you must allow less secure apps (https://myaccount.google.com/securit
import urllib.request, json
city = "Kiev"
api_key = "your api key"
city = "Insert Your City"
api_key = "Insert Your API Key"
units = "Insert your units (Default: Kelvin, Options: Metric, Imperial"
unit_key = "Insert your Unit Key(K, C, F)"
weather = eval(str(urllib.request.urlopen("http://api.openweathermap.org/data/2.5/weather?q={}&APPID={}".format(city, api_key)).read())[2:-1])
weather = eval(str(urllib.request.urlopen("http://api.openweathermap.org/data/2.5/weather?q={}&APPID={}&units={}".format(city, api_key, units)).read())[2:-1])
info = weather["weather"][0]["description"].capitalize()
temp = int(float(weather["main"]["temp"]) - 272.15)
temp = int(float(weather["main"]["temp"]))
print("%s, %i °C" % (info, temp))
print("%s, %i °%s" % (info, temp, unit_key))
```
## Module