本文共 466 字,大约阅读时间需要 1 分钟。
#!/usr/bin/python#Filename: backup_hxy.pyimport osimport time# source files and directories to be backed up in a list.source = ['D:\My test\Github', 'D:\My test\OpenCV']#backup dirtarget_dir = 'D:\My test\python'#target nametarget = target_dir + time.strftime('%Y %m %d %H %M %S') + '.zip'zip_command = "zip-qr '%s' %s" % (target,''.join(source))#run the backupif os.system(zip_command) == 0: print ('successful backup to', target)else: print ('backup failed')
转载地址:http://ceovi.baihongyu.com/