简明 Python 教程-win10下备份脚本

xiaoxiao2021-02-27  360

import os import time

import sys

#

sourc =r'C:\Users\zhuhui\Downloads\新建文件夹'  target_dir=r'D:\app\zhuhui' print (sourc) target = target_dir+time.strftime('%Y%m%d%H%M%S')+'.rar'  

print(target)

#winrar的安装路径

rar_command = r'"C:\Program Files (x86)\WinRAR\WinRAR.exe" a %s %s -r' % (target,sourc) if os.system(rar_command) == 0:     print ('Successful backup to', target) else:     print ('Backup FAILED')       
转载请注明原文地址: https://www.6miu.com/read-5575.html

最新回复(0)