Repozitář pro studenty IVE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
663 B

import requests
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib.animation as animation
response = requests.get("https://yesno.wtf/api")
if response.status_code == 200:
data = response.json()
print(data["answer"])
image_url = data["image"]
image_response = requests.get(image_url)
with open("image.gif","wb") as f:
f.write(image_response.content)
image = Image.open("image.gif")
num_frames = image.n_frames
def update_image(frame_num):
image.seek(frame_num)
plt.imshow(image)
anim = animation.FuncAnimation(plt.gcf(), update_image,interval=40,frames=num_frames)
plt.show()