python windows rar 压缩文件

#!/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)