我发现Pyglet有一个类,我可以用它加载zip文件: http://www.pyglet.org/doc/api/pyglet.resource.ZIPLocation-class.html
我是这样使用它的:
myzip = zipfile.ZipFile('testzip.zip')
myzip = pyglet.resource.ZIPLocation(myzip, '')
myzip = myzip.open('test.png', mode='rb')
但是它返回的是<StringIO.StringIO instance at 0x41ec670>
,所以我不能以我使用的方式使用pyglet.resource.image文件. 我得到的文件实际上是纯文本。有什么方法可以转换吗?你知道吗
我也试着弄清楚如何从拉链上加载文件。你知道吗
显然,ZIPLocation主要用于Pyglet在打开拉链时找到自己的路。您可以通过将ZIP文件添加到以下路径来打开它们:
好吧,我想它还没有实施。类所做的唯一事情就是在StringIO中返回文件的数据。用纯zipfile做这件事更容易。我就是这样做的:
相关问题 更多 >
编程相关推荐