tarfile — Read and write tar archive files
参考:
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的更多相关文章
- 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 ...
- 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 ...
- 如何解压POSIX tar archive文件
下载了一个xxx.gz的文件,使用x xxx.gz(zsh的x插件,十分之好用,再也不用担心tar后面该加哪些参数了)的命令解压,然后出现了一个文件,本以为解压后是一个文件夹:然后一脸蒙逼~ 突然又想 ...
- Linux tar This does not look like a tar archive
由于昨天公司内网服务器坏了,所以急需搭建新的Linux环境. 在安装maven时,使用tar 命令解压maven.tar.gz出现: tar :This does not look like a ta ...
- 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 ...
- Python教程大纲
缘起:最近想在部门推Python语言,写这个blog主要就是个教程大纲,之前先列出一些资源:Python历史:http://www.docin.com/p-53019548.html ...
- The Python Standard Library
The Python Standard Library¶ While The Python Language Reference describes the exact syntax and sema ...
- Modules you should know in Python Libray
前两天被问到常用的python lib和module有哪些?最常用的那几个,其他的一下子竟然回答不上.想想也是,一般情况下,遇到一个问题,在网上一搜,顺着线索找到可用的例子,然后基本没有怎么深究.结果 ...
- [Linux命令]tar命令
tar 命令的解释: tar(bsdtar): manipulate archive files First option must be a mode specifier: -c Create -r ...
随机推荐
- select 练习语句
select * from scott.dept; /查看scott.dept表中的全局信息. describe scott.emp: ...
- Apache支持TRACE请求漏洞处理方案
trace和get一样是http的一种请求方法,该方法的作用是回显收到的客户端请求,一般用于测试服务器运行状态是否正常. 该方法结合浏览器漏洞可能造成跨站脚本攻击.修复方法如下: 编缉/etc/htt ...
- Java逻辑
1.开发简单Java应用程序 1-1:什么是程序 程序:为了让计算机执行某些操作或解决某个问题而编写的一系列有序指令的集合.1-2:为什么学习Java Java是现在的主流1-3:Java可以做什么 ...
- unity中UI的屏幕自适应代码
public void ScreenUISelfAdptation(Transform scaleUI) { float widthrate = UnityEngine.Screen.width / ...
- bzoj4310
题解: 后缀数组求出本质不同的串 然后二分答案 贪心判断是否可行 代码: #include<bits/stdc++.h> ; using namespace std; typedef lo ...
- javascript es6系列教程 - 不定参数与展开运算符(...)
三个点(...)在es6中,有两个含义: 用在形参中, 表示传递给他的参数集合, 类似于arguments, 叫不定参数. 语法格式: 在形参面前加三个点( ... ) 用在数组前面,可以把数组的值 ...
- 图解前序遍历线索化二叉树,前序线索二叉树遍历,C\C++描述
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- 关于vivado implement后clock interaction报告的理解(更新中)
对于较大工程很难避免遇到CDC问题,vivado自带的分析工具可以报告跨时钟状态. 详情参看手册UG906-Design Analysis and Closure Techniques. (1)关于p ...
- Centos7安装ansible
CentOS下部署Ansible自动化工具 1.确保机器上安装的是 Python 2.6 或者 Python 2.7 版本: python -V 2.查看yum仓库中是否存在ansible的rpm包 ...
- JSP组件Telerik UI for JSP发布R1 2019 SP1|附下载
Telerik UI for JSP拥有由Kendo UI for jQuery支持的40+ JSP组件,同时通过Kendo UI for jQuery的支持能使用JSP封装包构建现代的HTML5和J ...