您的位置:首页 > 编程语言 > Python开发

使用Python在Windows下调用Winrar备份文件

2012-07-30 16:20 627 查看
import os
import time

source='C:\\Linda\\Test\\Python\\source'
target_dir='C:\\Linda\\Test\\Python\\backup\\'

target=target_dir + time.strftime('%Y%m%d%H%M%S')+'.rar'

print(target)

rar_command = "winrar a %s %s"%(target,source)
print (rar_command)

if os.system(rar_command)==0:
print ('Succeed to backup to', target)
else:
print ("Backup FAILED")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息