#!/usr/bin/python
# Filename: backup_ver1.py
import os
import time
source = [r'C:\Users\t_dingfeny\Desktop\pythonStudy\cleanupTest',
r'C:\Users\t_dingfeny\Desktop\pythonStudy\PSNRtest4']
target_dir = r'C:\Users\t_dingfeny\Desktop\pythonStudy'
target = target_dir + '\\' + time.strftime('%Y%m%d%H%M%S') + '.rar'
rar_command = "rar a %s %s" % (target, ' '.join(source))
#rar_command = "dir"
if os.system(rar_command) == 0:
print 'Successful backup to', target
else:
print 'Backup FAILED'
python windows rar 压缩文件
使用Python进行文件备份与RAR压缩
最新推荐文章于 2023-09-14 16:45:53 发布
本文介绍了一种利用Python脚本实现文件备份及使用RAR进行压缩的方法,包括脚本的基本结构、运行流程和成功反馈。适用于日常数据管理与保护。

481

被折叠的 条评论
为什么被折叠?



