我正在使用python的Turtle Graphics,我想设置一张背景图片。但是,它不起作用。我需要快速回答,因为明天我的计算机科学课程的任务> _<。这是我的代码:
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"
后面是无响应屏幕。谁知道错误是什么?