小白学python

简明python教程中:我想要一个可以为我的所有重要文件创建备份的程序。这个由于原作者是使用linux写的,所以zip—command在Windows系统下面会报错。在用info-zip和7zip无果的情况下,试了一下winrar命令,最后居然成功了。程序如下:

#!/usr/bin/python
#Filename:backup_verl.py


import os
import time


#The files and directories to be backed up are specified in a list
source=[r'E:\ds',r'F:\py123']


#The back up must be stored in a main backup directory
target_dir='/m n t/e/backup/' #Remember to change this to what you will be using




#The files are backed up into a zip file
#The name of the zip archive is the current date and time
target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip'


#sue the winrar command to put the files in a zip archive
WinRaR_command="WinRaR a {0} {1}".format(target,source)


#Run the backup
if os.system (WinRaR_command)==0:
    print'Sucessful back up to',target
else:
    print'Bcakup FAILED'


程序具体情况明天分析,朋友叫我跑步啦。遇到问题不要放弃,问题是用来解决而不是遗忘的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值