import turtle as t
import random as r
s = t.Screen()
image1 = "피자.jpeg"
image2 = "파스타.jpeg"
image3 = "삼겹살.jpeg"
image4 = "김치찌개.jpeg"
s.addshape(image1)
s.addshape(image2)
s.addshape(image3)
s.addshape(image4)
food = r.randrange(4)
if food == 0 :
t.shape(image1)
elif food == 1:
t.shape(image2)
elif food == 2:
t.shape(image3)
else:
t.shape(image4)
你出的什么错误
海龟图像只支持gif格式的图片,不支持jpeg格式的图片
我用gif格式的图片测试可以, 其他格式的图片不行
import turtle as t
import random as r
s = t.Screen()
image1 = "xxx1.gif"
image2 = "xxx2.gif"
image3 = "xxx3.gif"
image4 = "xxx4.gif"
s.addshape(image1)
s.addshape(image2)
s.addshape(image3)
s.addshape(image4)
food = r.randrange(4)
if food == 0 :
t.shape(image1)
elif food == 1:
t.shape(image2)
elif food == 2:
t.shape(image3)
else:
t.shape(image4)
t.done()
如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!