参考:

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. Oracle物理DG自动切换——Dataguard Broker配置

    1.前言部分 1.1 导读 各位技术爱好者,看完本文后,你可以掌握如下的技能: ① Data Guard Broker 的配置 ② Fast-Start Failover 的配置 ③ Oracle D ...

  2. 数据库恢复(database restore)之兵不血刃——半小时恢复客户数据库

    昨天,一个客户打打来电话,说他们的数据库坏了,不能用了,需要我帮助恢复下,这马上要放假了,居然出了这事儿,自己也不太喜欢恢复数据库这类,尤其是他们的数据库是个win上的库,但心里很清楚,客户比咱着急, ...

  3. 浏览器行为模拟之requests、selenium模块

    requests模块 前言: 通常我们利用Python写一些WEB程序.webAPI部署在服务端,让客户端request,我们作为服务器端response数据: 但也可以反主为客利用Python的re ...

  4. openssl修改版本号

    1.查看当前openssl版本号 openssl version 2.查看openssl所在位置 which openssl 3.查看保存版本号的libcrypto.so所在位置 ldd /usr/b ...

  5. 微信小程序生成二维码

    微信小程序客户端生成二维码的方法, 请参考这里: https://github.com/demi520/wxapp-qrcode  代码片段如下: const QR = require(". ...

  6. CAS5.3-下载安装

    cas版本:cas5.3 环境准备:1.JDK8:2.Apache Maven:3.Apache Tomcat:4.git 1.通过git工具(本文使用的是TortoiseGit,也可用IDE或者gi ...

  7. python xlrd使用

    python xlrd使用 1● xlrd安装   管理员模式           success 2● 引用 import xlrd    

  8. 回声TCP服务器端/客户端

    一.TCP服务端 1.TCP服务端的默认函数调用顺序 socket()创建套接字 bind()分配套接字地址 listen()等待请求连接状态 accept()允许连接 read()/write()数 ...

  9. error TS2304: Cannot find name 'Promise' && TS2307: Cannot find module '**'

    error TS2304: Cannot find name 'Promise' 解决方法:在编译选项中加入"target":"es6" { "ver ...

  10. 平面图转对偶图&19_03_21校内训练 [Everfeel]

    对于每个平面图,都有唯一一个对偶图与之对应.若G‘是平面图G的对偶图,则满足: G'中每一条边的两个节点对应着G中有公共边的面,包括最外部无限大的面. 直观地讲,红色标出来的图就是蓝色标出的图的对偶图 ...