file_dir = os.path.abspath(‘.‘) + "/MarkCoin" def zip_ya(): L = [] for root, dirs, files in os.walk(file_dir): for file in files: if os.path.splitext(file)[1] == ‘.png‘ or os.path.splitext(file)[1] == ‘.xlsx‘: L.append(file) z = zipfile.ZipFile(file_dir11 + ‘aa_file.zip‘, ‘w‘) for i in range(len(L)): z.write(file_dir11+L[i]) z.close() if __name__ == ‘__main__‘: zip_ya()
原文地址:https://www.cnblogs.com/ioswws/p/10072358.html
时间: 2024-12-15 04:30:24