参考:

https://docs.python.org/2/library/tarfile.html

http://www.jianshu.com/p/bbad16822eab

#解压文件
tarfile.open(filepath, 'r:gz').extractall(inception_pretrain_model_dir)

python中os.walk的用法

如下的文件结构:

 a ->   b   ->   .txt,  .txt
             c   ->   .txt
             d   ->
           .txt
           .txt
for (root, dirs, files) in os.walk('a'):
    #第一次运行时,当前遍历目录为 a
    所以 root == 'a'
         dirs == [ 'b', 'c', 'd']
         files == [ '4.txt', '5.txt']

    。。。

    # 接着遍历 dirs 中的每一个目录
    b:  root  = 'a\\b'
        dirs  = []
        files = [ '1.txt', '2.txt']

    # dirs为空,返回
    # 遍历c
    c:  root  = 'a\\c'
        dirs  = []
        files = [ '3.txt' ]

    PS : 如果想获取文件的全路径,只需要
    for f in files:
        path = os.path.join(root,f)

    # 遍历d
    d:  root  = 'a\\b'
        dirs  = []
        files = []

    遍历完毕,退出循环

tarfile — Read and write tar archive files的更多相关文章

  1. How to append files to a .tar archive using Apache Commons Compress?(转)

    I created a copy of the tar archive and copied to entire content to it. Then I delete the old tar ar ...

  2. tar: This does not look like a tar archive tar: Skipping to next header tar: Exiting with failure status due to previous errors

    解压一个.tar.zip文件时报错 tar -zxvf bcl2fastq2-v2---linux-x86-.zip tar: This does not look like a tar archiv ...

  3. 如何解压POSIX tar archive文件

    下载了一个xxx.gz的文件,使用x xxx.gz(zsh的x插件,十分之好用,再也不用担心tar后面该加哪些参数了)的命令解压,然后出现了一个文件,本以为解压后是一个文件夹:然后一脸蒙逼~ 突然又想 ...

  4. Linux tar This does not look like a tar archive

    由于昨天公司内网服务器坏了,所以急需搭建新的Linux环境. 在安装maven时,使用tar 命令解压maven.tar.gz出现: tar :This does not look like a ta ...

  5. WebJars are client-side web libraries (e.g. jQuery & Bootstrap) packaged into JAR (Java Archive) files

    webjars网站https://www.webjars.org/,这里将很多的东西都打包成了jar包,想要用什么只需要导入相关的依赖就可以了. 比如springboot会用到jquery,webja ...

  6. Python教程大纲

    缘起:最近想在部门推Python语言,写这个blog主要就是个教程大纲,之前先列出一些资源:Python历史:http://www.docin.com/p-53019548.html          ...

  7. The Python Standard Library

    The Python Standard Library¶ While The Python Language Reference describes the exact syntax and sema ...

  8. Modules you should know in Python Libray

    前两天被问到常用的python lib和module有哪些?最常用的那几个,其他的一下子竟然回答不上.想想也是,一般情况下,遇到一个问题,在网上一搜,顺着线索找到可用的例子,然后基本没有怎么深究.结果 ...

  9. [Linux命令]tar命令

    tar 命令的解释: tar(bsdtar): manipulate archive files First option must be a mode specifier: -c Create -r ...

随机推荐

  1. group by 错误

    出现错误: which is not functionally dependent on columns in GROUP BY clause; this is incompatible with s ...

  2. zk 创建瞬时、顺序节点的原理

    命令: create -s -e /worker/lock xx zk 的实现代码在:PrepRequestProcessor.pRequest2Txn 中 //The number of chang ...

  3. telnet强制中断登录

    在telnet登录的时候,有时我们只是想测试某个账号密码是否正确 但是telnet不像ssh一样密码试错之后可以使用Ctrl+c强制中断,使如果要输错三次五次才给退出中断交互那是十分浪费时间和心情的 ...

  4. cpu占用过高排查

    top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器 内容解释: PID:进程的ID USER:进程所有者 PR:进程的优先级别,越小 ...

  5. js 操作dom

    childNodes 返回当前元素所有子元素的数组 parentNode 返回元素的父节点 document.createElement(tagName) 文档对象上的createElement方法可 ...

  6. 【转】Java中static关键字用法总结

    1.     静态方法 通常,在一个类中定义一个方法为static,那就是说,无需本类的对象即可调用此方法 声明为static的方法有以下几条限制: · 它们仅能调用其他的static 方法. · 它 ...

  7. vue-1-模板语法

    文本 <span>Message: {{ msg }}</span><span v-once>这个将不会改变: {{ msg }}</span> 原始 ...

  8. SQLite3 C/C++ 开发接口简介

    SQLite3 C/C++ 开发接口简介 1.0 总览 SQLite3是SQLite一个全新的版本,它虽然是在SQLite 2.8.13的代码基础之上开发的,但是使用了和之前的版本不兼容的数据库格式和 ...

  9. java 设计模式参考资料

    参考博客 http://www.cnblogs.com/lin3615/p/3783272.html 设计模式之责任链模式http://www.cnblogs.com/draem0507/p/3784 ...

  10. redis 五大数据类型之sortedset

    个人理解,这就是一个有序的set集合 他就是根据每个key创建的时候根据score值大小进行排序(score值仅限支持float型) 1.zadd/zrange(zadd  key score mem ...