import urllib2 import json import time # Look up POP in near Future def pop(a): f = urllib2.urlopen('http://api.wunderground.com/api/003508f51f58d4f4/geolookup/forecast/q/WI/Black_Earth.json') json_string = f.read() parsed_json = json.loads(json_string) pop= parsed_json['forecast']['txt_forecast']['forecastday'][a]['pop'] return pop def weather(): x=pop(0) print ("Chance of rain rain today")+" "+x y=pop(1) print ("Chance of rain rain tonight")+" "+y if int(x)<10 and int(y)<10: print ("You need to water the plants!") else: print("Drink and beer, you are done for the day!") for x in range(3): weather() time.sleep(10)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question