如何更改zip存档的标题(PK到PIRAKA)?我在python中更改了zipfile模块。我需要创建一个带有标题PIRAKA而不是PK的zip存档(存档结果创建)。问题是你无法在'r'模式下打开文件.Pirfile
只需以二进制模式更改ZIP文件内容:
with open('file.zip', 'rb') as f:
data = f.read().replace(b'PK', b'PIRAKA')
with open('result.zip', 'wb') as f:
f.write(data)
输入ZIP文件头:
PK ™QЉNLщFCё ...
输出ZIP文件头:
PIRAKA ™QЉNLщFCё ...