0
我正在使用python的龜圖形,我想設置一個背景圖片。但是,它不起作用。我需要一個快速答案,因爲我明天有一個計算機科學課的作業> _ <。這裏是我的代碼:Python - 'bgpic'不工作
import time
import sys
import turtle
##Render
turtle.bgpic("background.png")
##End
turtle.done()
而且我得到這個錯誤:
Traceback (most recent call last):
File "C:/Users/Alfie/Desktop/Youtube Game/Youtube.py", line 6, in <module>
turtle.bgpic("background.png")
File "<string>", line 8, in bgpic
File "C:\Python27\lib\lib-tk\turtle.py", line 1397, in bgpic
self._bgpics[picname] = self._image(picname)
File "C:\Python27\lib\lib-tk\turtle.py", line 503, in _image
return TK.PhotoImage(file=filename)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 3366, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 3320, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
TclError: couldn't recognize data in image file "background.png"
遵循的無響應屏幕。任何人都知道錯誤是什麼?
事實上,turtle包的文檔聲稱它只支持[.bgpic](https://docs.python.org/2/library/turtle.html#turtle.bgpic)中背景的.gif圖像。 –
謝謝<3我會試試! –