免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2641 | 回复: 6
打印 上一主题 下一主题

windows python 用户调用zip命令 问题来自 简明python 教程 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-05-04 21:21 |只看该作者 |倒序浏览
第十章中貌似 只给了Linux的解决方法  说windows用户要使用info-zip 程序  请问大神们 我该如何使用

论坛徽章:
0
2 [报告]
发表于 2013-05-04 22:23 |只看该作者
求 会的帮俺解答解答呗

论坛徽章:
0
3 [报告]
发表于 2013-05-04 22:24 |只看该作者
#!/usr/bin/python
# Filename: backup_ver1.py
import os
import time
# 1. The files and directories to be backed up are specified in a list.
source = ['/home/swaroop/byte', '/home/swaroop/bin']
# 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 = '/mnt/e/backup/' # 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'

论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
4 [报告]
发表于 2013-05-05 19:16 |只看该作者
回复 1# super恋


    我记得有ZipFile这个类,可以用这个来进行,ZipFile

论坛徽章:
0
5 [报告]
发表于 2013-05-07 19:51 |只看该作者
回复 4# jeppeter


    好滴 谢谢咯 抓紧去拜读一下

论坛徽章:
0
6 [报告]
发表于 2013-05-17 17:18 |只看该作者
朋友解决了吗

论坛徽章:
0
7 [报告]
发表于 2013-05-17 22:51 |只看该作者
本帖最后由 GhostFromHeaven 于 2013-05-17 22:52 编辑

先思考,然后搜索,再提问

http://lixiaorong223.blog.163.co ... 629201272471221231/

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP