参考:

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. springboot自动装配

    Spring Boot自动配置原理 springboot自动装配 springboot配置文件 Spring Boot的出现,得益于“习惯优于配置”的理念,没有繁琐的配置.难以集成的内容(大多数流行第 ...

  2. python3使用requests模块完成get/post/代理/自定义header/自定义Cookie

    一.背景说明 http请求的难易对一门语言来说是很重要的而且是越来越重要,但对于python一是urllib一些写法不太符合人的思维习惯文档也相当难看,二是在python2.x和python3.x中写 ...

  3. 把旧系统迁移到.Net Core 2.0 日记(5) Razor/HtmlHelper/资源文件

    net core 的layout.cshtml文件有变化, 区分开发环境和非开发环境. 开发环境用的是非压缩的js和css, 正式环境用压缩的js和css <environment includ ...

  4. js中如何通过身份证号计算出生日期和年龄

    在html中有如下标签 身份证号:<input type="text" id="Gra_IDCard" onChange="IDCardChan ...

  5. Best Paper Awards in Computer Science 链接

    http://jeffhuang.com/best_paper_awards.html#icml

  6. Win10系列:VC++绘制几何图形3

    在绘制三角形之前,首先需要创建一个三角形,打开D2DBasicAnimation.h头文件,在D2DBasicAnimation类中添加如下的代码: private:     //声明成员变量obje ...

  7. 整数中1出现的次数(1~n)

    题目描述 求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1.10.11.12.13因此共出现6次,但是对于后面问题他就没辙了. ...

  8. mybatis输出sql语句

    方法一: 这种方法是mybatis官网上介绍的,比较好用: log4j.properties: log4j.rootLogger=ERROR,consolelog4j.appender.console ...

  9. Grafana的安裝(一)

    Grafana的安裝 grafana是用于可视化大型测量数据的开源程序,他提供了强大和优雅的方式去创建.共享.浏览数据.dashboard中显示了你不同metric数据源中的数据 Granafa的安裝 ...

  10. 手动配置 Windows 时间服务

    手动配置 Windows 时间服务 要将内部时间服务器配置为与外部时间源同步,请按照下列步骤操作: 将服务器类型更改为 NTP. 为此,请按照下列步骤操作: 选择 “开始” . “运行”,键入 reg ...