Python 错误:无法从 RWops 读取 [英] Python Error: Couldn't read from RWops
本文介绍了Python 错误:无法从 RWops 读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过加载文件然后播放来使用 tkinter 和 pygame 制作一个小型音乐播放器.如果我将文件名放入
I'm trying to make a small music player with tkinter, and pygame, by loading a file and then playing it. Everything works fine if I place the file-name into
pygame.mixer.music.load('filename.mp3')
但是如果我尝试用
file = tkinter.filedialog.askopenfile()
pygame.mixer.music.load(file)
然后我浏览到文件并点击打开,我收到一个错误提示
and I browse to the file and click open, I get an error which says
python.error: Couldn't read from RWops
任何导致这种情况的线索?
Any clues onto what is causing this?
推荐答案
askopoenfile
返回打开文件的句柄.如果您想要一个文件 name,请改为调用 askopenfilename
.
askopoenfile
returns a handle to an open file. If you want a file name, call askopenfilename
instead.
这篇关于Python 错误:无法从 RWops 读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文