[英]How can I extract a zip archive that contains a forbidden file name on Windows using Python?
I've been trying to write a Python program to assist with installing Minecraft mods. 我一直在尝试编写Python程序来协助安装Minecraft mod。 This requires extracting an obfuscated JAR file and adding some new classes.
这需要提取混淆的JAR文件并添加一些新类。 However, one of the obfuscated files is called
aux.class
. 但是,混淆文件之一称为
aux.class
。 Any file named aux
, no matter what extension, is forbidden on Windows due to it being a DOS device name. Windows中禁止使用任何名为
aux
文件(无论扩展名如何),因为该文件是DOS设备名称。 I need to figure out some way to extract this file and then rearchive it while keeping Windows happy. 我需要找出一些方法来提取此文件,然后在使Windows满意的同时对其进行归档。 How can I do this?
我怎样才能做到这一点?
you don't have to write the file, or extract it. 你不必写入文件,或将其解压缩。 you can use
您可以使用
toolzip = zipfile.ZipFile(myzipfile, 'r')
names = toolzip.namelist()
for n in names:
data = toolzip.read(n)
# do something with data
including writing the data back to another zip. 包括将数据写回到另一个zip。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.