看过 简明 python 教程 的帮忙解答:第十章的写一个备份脚本文件,

编程入门 行业动态 更新时间:2024-10-28 06:22:33
看过 简明 python 教程 的帮忙解答:第十章的写一个备份脚本文件, #!/usr/bin/env python # Filename: backup_ver1.py import sys import os import time # 1. The files and directories to be backed up are specified in a list. source=[r'C:\work1',r'D:\Work'] # If you are using Windows, use source=[r'C:\Documents',r'D:\Work'] or something like that # 2. The backup must be stored in a main backup directory target_dir=r'D:\yss' #Remember to change this to what you will be using # 3. The files are backed up into a zip file # 4. The name of the zip archive is the current date and time target=target_dir+time.strftime('%Y%m%d%H%M%S')+'.zip' # 5. We use the zip command (in Unix/Linux) to put the files in a zip archive zip_command="zip -qr '%s' %s" %(target,' '.join(source)) # Run the backup if os.system(zip_command)==0: print 'Successful backup to',target else: print 'Backup FAILED' 我运行后返回的是 Backup FAILED 什么原因照成的啊!

最满意答案

是不是路径不存在之类的?还有其他输出吗? 在这句zip_command="zip -qr '%s' %s" %(target,' '.join(source))后面加个 print zip_command 然后把这句拷下来,直接运行看看结果

更多推荐

本文发布于:2023-08-04 22:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423109.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:第十章   简明   脚本   备份   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!