from PIL import Image
Pikachu=Image.open('pikachu.png')
Charizard=Image.open('charizard.png')
pokemon_list=('PIKACHU','CHARIZARD')
picture={'PIKACHU':Pikachu,'CHARIZARD':Charizard}
Pokemon=pokemon_list[Count]
Count=0
while (Count!=3):
picture[Pokemon]
Count+=1当它在一个循环中时,它不会出现,我如何使它工作?
发布于 2022-02-06 09:52:04
这是因为你把它称为错误的顺序。注意,列表中有两个元素,所以您不能获得比1更多的对象,并且需要在rb模式下打开文件。
最后,要使用show an Image,您必须使用该函数:show()。
这里的完整代码:
from PIL import Image
Pikachu = open('1.jpg', 'rb')
Charizard = open('2.jpg', 'rb')
pokemon_list = ('PIKACHU', 'CHARIZARD')
picture = {'PIKACHU': Pikachu, 'CHARIZARD': Charizard}
Count = 0
while Count < 2:
Pokemon = pokemon_list[Count]
Image.open(picture[Pokemon]).show()
Count += 1https://stackoverflow.com/questions/71005882
复制相似问题