标签:pre coding ack backup ott python item div 备份
#!/usr/bin/python # coding:utf-8 import os import sys import zipfile import time def doZip(zipFile,old): for item in os.listdir(old): if os.path.isdir(old+os.sep+item): doZip(zipFile,old+os.sep+item) else: zipFile.write(old+os.sep+item) try: import zlib mode = zipfile.ZIP_DEFLATED except: mode = zipfile.ZIP_STORED old = ‘d:‘+os.sep+‘WWW‘+os.sep+‘LotteryV2‘+os.sep backup = ‘d:‘+os.sep+time.strftime(‘%Y%m%d‘)+‘.zip‘ if os.path.exists(backup): print(‘今日已经备份了‘) guess = input(‘是否要覆盖备份?y/n‘) if guess == ‘n‘: print(‘终止备份‘) sys.exit() else: print(‘覆盖备份‘) print(‘请等候...‘) pass zipFile = zipfile.ZipFile(backup, ‘w‘,mode) if os.path.isdir(old): doZip(zipFile,old) zipFile.close()
标签:pre coding ack backup ott python item div 备份
原文地址:https://www.cnblogs.com/LoveJulin/p/8759245.html