gpt4 book ai didi

python - 使用绝对路径的 Pyglet 加载资源

转载 作者:太空宇宙 更新时间:2023-11-04 03:44:40 25 4
gpt4 key购买 nike

<分区>

我是 python 的新手,我对此进行了一些研究,但我找到的答案似乎不起作用。我试图用带有绝对路径的 pyglet 加载一个 mp3 文件,但它给出了这个错误:

Traceback (most recent call last):
File "C:\Apps\Python\lib\site-packages\pyglet\resource.py", line 624, in media
location = self._index[name]
KeyError: 'C:/Users/Ruurd/Google Drive/Script/Python/music2.mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Ruurd/Desktop/playmus.py", line 3, in <module>
music=pyglet.resource.media(path)
File "C:\Apps\Python\lib\site-packages\pyglet\resource.py", line 634, in media
raise ResourceNotFoundException(name)
pyglet.resource.ResourceNotFoundException: Resource "C:/Users/Ruurd/Google Drive/Script/Python/music2.mp3" was not found on the path. Ensure that the filename has the correct captialisation.

当我使用“music2.mp3”作为路径时,它工作正常。这是无效代码

import pyglet
path='C:/Users/Ruurd/Google Drive/Script/Python/music2.mp3'
music=pyglet.resource.media(path)
music.play()

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com