zipfile write()方法支持一个额外的参数(arcname),该参数是要存储在zip文件中的档案名称,因此您只需使用以下命令更改代码:
from os.path import basename...zip.write(first_path, basename(first_path))zip.write(second_path, basename(second_path))zip.close()
如果您有空闲时间,请阅读zipfile文档。

zipfile write()方法支持一个额外的参数(arcname),该参数是要存储在zip文件中的档案名称,因此您只需使用以下命令更改代码:
from os.path import basename...zip.write(first_path, basename(first_path))zip.write(second_path, basename(second_path))zip.close()
如果您有空闲时间,请阅读zipfile文档。