- 浏览: 441049 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (538)
- C/C++ Primer (69)
- Objective-C Primer (102)
- Python Primer (19)
- JavaScript Primer (1)
- Java Primer (37)
- PHP Primer (17)
- 泛 Linux (37)
- Shell Script (21)
- APUE (21)
- UNP__1&2 (19)
- NetWork (7)
- Oracle周边 (38)
- Mysql里边 (6)
- Windows技 (9)
- 简单算法 & 数据结构 (14)
- 设计模式 (6)
- GTK历程 (12)
- 工具使用 (25)
- 杂事 (23)
- 一些概念 (17)
- Web方面 (10)
- myCodeTools (9)
- ^未 竟$ (13)
- 硬件通信 (2)
- Games (1)
最新评论
前几天用了下zip,要压缩个目录,下面那坨代码也是copy回来的...
当时比较匆忙,忘记了原文地址=。=
好久没写过脚本了,python更是N久没动过,脚本好使啊
#!/usr/bin/python #coding=utf-8 import os import shutil,string import zipfile from os.path import join # 直接导入到局部名字空间,所以它可以直接使用,而不需要加上模块名的限定。 # 你可以导入独立的项或使用 from module import * 来导入所有东西。 # 像 Java 中的 import module.* ; #打包、压缩当前目录folder def zipfolder(foldername, filename, includeEmptyDIr=True): empty_dirs = [] zip = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) for root, dirs, files in os.walk(foldername): empty_dirs.extend([dir for dir in dirs if os.listdir(join(root, dir)) == []]) for name in files: path = join(root ,name) print path zip.write(join(root ,name)) if includeEmptyDIr: for dir in empty_dirs: zif = zipfile.ZipInfo(join(root, dir) + "/") zip.writestr(zif, "") empty_dirs = [] zip.close() print os.path.abspath('.') dir = './' filelist = os.listdir(dir) for file in filelist: path = dir+file target = dir + file + '.zip' zipfolder(path, target)
发表评论
-
webpy_Cookbook
2013-05-06 22:31 576http://webpy.org/cookbook/index ... -
webpy_CGI 伏笔
2013-05-06 10:18 1092http://webpy.org/install.zh-cn ... -
app PNG
2013-03-22 11:53 882#--- # iPIN - iPhone PNG Images ... -
python__re
2013-03-19 17:49 578xpath解析html,使用正则不好... http://ww ... -
Django
2013-03-03 20:04 962https://docs.djangoproject.com/ ... -
bpython IDE
2013-02-27 11:51 649http://bpython-interpreter.org/ ... -
install webpy
2012-07-20 20:58 569http://webpy.org/install.zh-cn ... -
Python__列表
2011-02-12 14:23 602http://gmingzhe.blog.51cto.com/ ... -
Python__参数:传值or引用?
2011-02-12 14:20 589http://blog.csdn.net/winterTTr/ ... -
Python__递归遍历文件
2011-02-12 12:54 800http://zhangjunhd.blog.51cto.co ... -
Python__升级
2011-02-12 10:57 889http://www.activestate.com/ 出处 ... -
Python__模块
2011-02-11 15:48 743什么是模块:sys、time等模块,已经被封装起来,我们经常在 ... -
Python__函数
2011-02-11 15:18 679最基本函数 #!/usr/bin/python de ... -
Python__时间
2011-02-11 15:15 554当前时间 遍历时间 时间截 -
常用模块介绍
2010-07-22 15:48 610http://blog.csdn.net/Xiao_Qiang ... -
python编码相关
2010-07-22 09:54 961http://blog.csdn.net/lwl_ls/arc ... -
Python函数库列表
2010-07-21 21:05 1251copy:http://blog.ez2learn.com ... -
python__init
2010-05-27 10:22 587http://blog.sina.com.cn/s/artic ...
相关推荐
python ssd1306 driver
Book for study Python
python地铁客流量分析平台_python毕业设计_爬虫可视化_论文_python_毕业论文_源码.zip
CNN-SVM_SVMCNN_SVM特征提取_SVM_python_SVM分类_源码.zip
python 批量读取目录文件下的excel文件
Python_django_cheatsheet
rtasr_python_demo_语音转写_语音python_DEMO.zip
aa_python_Decoded_ionCube_源码.zip
python_code.zip
Python_avoidxy8_svrpython_python回归svr_SVR_SVR_源码.zip
weibo_spider_爬虫python_关键词爬虫_python_python爬虫_spider.zip
PythonSIFT_sift配准_SIFT算法python_sift_siftpython_nan_源码.zip
python tsp_pythonvrp模型_pythonvrp_python_vrp算法python_vrp.zip
代码挑战:Python_Python_下载.zip
think-python-2nd_thinkpython_python_
python_SVM_svrpython_SVR回归预测_SVR_svr预测_源码.zip
油藏模拟Excel+Python_Python_下载.zip
python_几种LLE_llepython_LLE算法Python_降维算法_源码.zip
rtasr_python_demo_语音转写_语音python_DEMO_源码.zip
house price_python预测_house_python预测_python_python课件_源码.zip