gpt4 book ai didi

python - 在Python中创建一个lzma文件

转载 作者:太空宇宙 更新时间:2023-11-03 19:36:48 28 4
gpt4 key购买 nike

我需要使用现有的 .tar 文件和另一个元数据文件创建一个 lzma 文件,以进一步创建 zip 文件。

最佳答案

第一download/install PyLZMA 。在您的程序中,按照描述使用它 here 。要创建 zip,您可以使用 zipFile - 标准库的模块,有效 as follows :

# open the zip file for writing, and write stuff to it

file = zipfile.ZipFile("test.zip", "w")

for name in a_demo_list_of_files:
file.write(name, os.path.basename(name), zipfile.ZIP_DEFLATED)

file.close()

希望对你有帮助!

关于python - 在Python中创建一个lzma文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3192001/

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