[CentralOH] Code from last night's Beginner's Python talk

Peter Carswell pcarswell.1 at gmail.com
Thu Oct 1 21:59:16 CEST 2015


Eric,

Thanks. I was just talking to a fellow faculty who has a nsf grant for
network security. It specifies the development of a python course. He an I
will be working on that. I had described your presentation and he was very
interested.

pete

On Tue, Sep 29, 2015 at 2:50 PM, Eric Floehr <eric at intellovations.com>
wrote:

> import urllib2
>
> # The API url to call
> key = 'f6a..........15a'
> url = '
> http://api.wunderground.com/api/{key}/geolookup/conditions/q/France/Paris.json'.format(key=key)
>
> # Open the page and store as a string
> page = urllib2.urlopen(url)
> json_string = page.read()
> page.close()
>
> # Read the string and parse as JSON data
> data = json.loads(json_string)
>
> # Pull out information from the JSON data
> location = data['location']['city']
> obs = data['current_observation']
> temp_f = obs['temp_f']
> condition = obs['weather']
>
> print("In {loc} it is {temp:.0f} and {cond}".format(loc=location,
> temp=temp_f, cond=condition))
>
>
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> https://mail.python.org/mailman/listinfo/centraloh
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/centraloh/attachments/20151001/b2dd1d31/attachment.html>


More information about the CentralOH mailing list