Created
February 3, 2021 08:32
-
-
Save esmitt/8bcdb842b7c1206052f18bf9e4b08e66 to your computer and use it in GitHub Desktop.
Mostrar la imagen de un pikachu utilizando pokeapi.co. Pensado para ser desplegado en una ventana emergente en PyCharm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first, install requests and matplotlib (pip install requests matplotlib) | |
from urllib.request import urlopen | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
import requests | |
api_url_pokemon = 'https://pokeapi.co/api/v2/pokemon/pikachu' | |
result = requests.get(api_url_pokemon) | |
if result.status_code == 200: | |
pokemon_data = result.json() | |
url_image = pokemon_data['sprites']['other']['official-artwork']['front_default'] | |
im = Image.open(urlopen(url_image)) | |
plt.imshow(im) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment