首页 > 编程语言 > 详细

python 调用rar命令行 压缩文件

时间:2016-06-04 16:13:39      阅读:242      评论:0      收藏:0      [点我收藏+]

通过os模块的system()方法调用了系统的rar.exe命令,这个方法会返回一个变量exit_status

import os
import time

source = [rD:\Work\Python\Demo, d:\\work\\linux]
target_dir = D:\\Work\\backup\\

target = target_dir + time.strftime(%Y%m%d%H%M%S) + .rar
zip_command = "rar a %s %s" % (target,  .join(source))

if os.system(zip_command) == 0:
    print Sucessful backup to, target
else:
    print Backup Failed

 

python 调用rar命令行 压缩文件

原文:http://www.cnblogs.com/xunbu7/p/5558822.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!