我在Internet上有一个简单的Python代码来创建目录的zip存档。它工作了一段时间但现在,但现在当我运行Python脚本时,我收到一个错误。
这是我的Python代码:
import os
import zipfile
fantasy_zip = zipfile.ZipFile('archive.zip', 'w')
for folder, subfolders, files in os.walk('Photos cadre'):
for file in files:
fantasy_zip.write(os.path.join(folder, file), os.path.relpath(os.path.join(folder,file), 'Photos cadre'), compress_type = zipfile.ZIP_DEFLATED)
fantasy_zip.close()
这是我得到的错误:
Traceback (most recent call last):
File "/Users/ryandanenberg/Desktop/Programmation/Python/Serveur Python/Drive/zipfile.py", line 3, in <module>
import zipfile
File "/Users/ryandanenberg/Desktop/Programmation/Python/Serveur Python/Drive/zipfile.py", line 6, in <module>
fantasy_zip = zipfile.zipFile('archive.zip', 'w')
AttributeError: module 'zipfile' has no attribute 'zipFile'