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 ...
随机推荐
- Linux中环境变量文件
一.环境变量文件介绍 转自:http://blog.csdn.net/cscmaker/article/details/7261921 Linux中环境变量包括系统级和用户级,系统级的环境变量是每个登 ...
- elasticsearch在CentOS环境下开机启动
验证环境,OS版本:CentOS-7-x86_64-Minimal-1708:ES版本:elasticsearch-6.2.2. 1.创建文件elasticsearch #!/bin/bash # # ...
- npm node sass 安装报错
报错为 不能找到python2.7,记得曾经已经安装过python,结果npm install cnpm install npm install node-sass 各种不行,结果在cmd 输入pyt ...
- vsCode快捷键设置
// 快捷键设置 keyiing.json // 将键绑定放入此文件中以覆盖默认值 [ /* // 转换大写 { "key" : "ctr ...
- jq 如何获取多选框选中的值
jquery如何获取多选框选中的值,有两种方法 1.通过id获取是否选中(单个) 1)引入jquery文件 2)Html设计如下 <div> <span>运动类:</sp ...
- Win10系列:JavaScript 项目模板中的文件和项模板文件
通过上面内容的学习,相信读者已经对各种项目模板和项模板有了大致的了解,本节将进一步介绍项目模板中默认包含的项目文件以及项模板文件,首先讲解这些文件中的初始内容以及作用,然后介绍在一个页面中如何添加控件 ...
- OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django'
http://blog.csdn.net/qq_34078897/article/details/50821553 权限问题,sudo
- UVA LA 3983 - Robotruck DP,优先队列 难度: 2
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- 常见的SQLALCHEMY列类型
常见的SQLALCHEMY列类型.配置选项和关系选项 类型名称 python类型 描述 Integer int 常规整形,通常为32位 SmallInteger int 短整形, ...
- python中的__call__()函数
__call__ 在Python中,函数其实是一个对象: >>> f = abs >>> f.__name__ 'abs' >>> f(-123) ...