[CentralOH] Web API usage demo
Catherine Devlin
catherine.devlin at gmail.com
Fri Feb 26 20:31:50 EST 2021
Ha, glad to hear it! f-strings are for *everything*. They're really
wonderful... and also a little bit terrifying. f-strings and all their
evolutionary ancestors in the string templating world would be a good dojo
topic, now that I think about it.
On Fri, Feb 26, 2021 at 2:39 PM Bryan Harris <brywilharris at gmail.com> wrote:
> Every single time I see some of your code, you're using some new
> feature of Python I've never seen before. I had to look up what the
> f-strings were for.
>
> Bryan Harris
> brywilharris at gmail.com
>
> On Thu, Feb 25, 2021 at 8:19 PM Catherine Devlin
> <catherine.devlin at gmail.com> wrote:
> >
> > Hi, folks! I did a little demo at Thursday's dojo of using requests to
> get JSON data from a RESTful API, so here's the code:
> >
> > import requests
> > BASE_URL = 'https://ghibliapi.herokuapp.com'
> > url = f"{BASE_URL}/people"
> > people = requests.get(url).json()
> > for person in people:
> > print(person['name'])
> > for film in person['films']:
> > film_response = requests.get(film)
> > print(f" {film_response.json()['title']}")
> >
> > Of course, you'll need to `pip install requests` first...
> >
> > --
> > - Catherine
> > http://catherinedevlin.blogspot.com
> > _______________________________________________
> > CentralOH mailing list
> > CentralOH at python.org
> > https://mail.python.org/mailman/listinfo/centraloh
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> https://mail.python.org/mailman/listinfo/centraloh
>
--
- Catherine
http://catherinedevlin.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/centraloh/attachments/20210226/1478eaf4/attachment.html>
More information about the CentralOH
mailing list