wqee2 发表于 2015-5-28 08:43:35

Python写的备份目录文件的脚本

                      #!/usr/bin/python
# -*- coding: utf-8 -*-
#filename back.py
#author superchen

import os
import time
source ='/home/shiyanlou/Documents/'
target_dir = '/home/shiyanlou/Desktop'
target = target_dir+time.strftime('%Y-%m-%d-%H-%M-%S')+'.zip'
zip_command = "zip -qr %s %s" %(target,''.join(source))
#q命令是安静运行r命令是递归的执行
if os.system(zip_command)==0:
    print 'sucessful backup'
else:
    print "backup failed"

                   

页: [1]
查看完整版本: Python写的备份目录文件的脚本