Skip to content

Instantly share code, notes, and snippets.

@esmitt
Created February 3, 2021 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esmitt/8bcdb842b7c1206052f18bf9e4b08e66 to your computer and use it in GitHub Desktop.
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.
# 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