Python tarfile模块解压报错 invalid mode ('wb') or filename
问题原因
在使用tarfile模块解压一份Linux服务器上的打包文件时, 出现了错误提示: IOError: [Errno 22] invalid mode ('wb') or filename.
经过检查, 发现是因为打包文件中有文件名存在':'符号, 而window下的文件名是不能有':'符号的因而报错.
解决办法
通过搜索, 找到了种解决办法, 可以将解压时含':'的地方转换成'_'等正常的符号
extract = tarfile.open(file)
for f in extract:
# add other unsavory characters in the brackets
f.name = re.sub(r'[:]', '_', f.name)
extract.extractall(path=new_path)
extract.close()
来源
Python tarfile模块解压报错 invalid mode ('wb') or filename的更多相关文章
- MongoDB解压报错gzip: stdin: not in gzip format的解决方法
MongoDB解压报错gzip: stdin: not in gzip format的解决方法 在安装MongoDB时出现如下报错: [root@vm172--- mongodb]# tar -zxv ...
- linux下 python源码包解压报错
执行下面的命令 tar -zvxf Python.3.6.5.tgz 报错 gzip: stdin: not in gzip format tar: Child returned status 1 t ...
- memcached解压报错gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now的解决方法
最近在部署环境,在安装memcached的过程中解压时, 解压命令:tar -zvxf memcached-1.4.34.tar.gz 遇到了一个问题, gzip: stdin: not in gzi ...
- 解压报错gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now的解决方法
在部署tomcat的环境搞JDK的时候出现这个问题.分享一下. 解压命令:tar -zvxf memcached-1.4.34.tar.gz 遇到了一个问题, gzip: stdin: not in ...
- python安装模块的时候报错error: command 'gcc' failed with exit status 1
[情况] 在写Python代码的时候,需要用到psutil模块,需要安装. 但是在安装时,报错:error: command 'gcc' failed with exit status 1 [解决步骤 ...
- linux下unzip解压报错“symlink error: File name too long”怎么办?提供解决方案。
点击上方↑↑↑蓝字[协议分析与还原]关注我们 " 分享unzip工具的一个bug." 最近在研究菠菜站,中间用到了Spidermonkey,碰到一些小波折,在这里分享出来,以便大家 ...
- Unzip 解压报错
$ jar xvf pcre-8.10.zip 如果出现 jar:Command not found 要用yum下载 $ yum -y install java-1.6.0-openjdk-d ...
- Python压缩及解压文件
Zip压缩 #-*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" import zipfile #加载模块 # 压缩 z = zipf ...
- python安装包的时候报错
python安装包的时候报错 今天兴致勃勃的安装了一个paramiko包,过程很顺利,但是到结尾的时候报错,这就让人不爽了. 所以呢,需要安装一个名为python-dev的软件包. 该软件包包括头文件 ...
随机推荐
- [postgresql]ROWS is not applicable when function does not return a set问题解决
需要把程序结尾的ROWS 1000去掉,提示如果函数不是返回一个数据集的情况下ROWS是不适用的: CREATE OR REPLACE FUNCTION public.function( eigyou ...
- 《高级Web应用程序设计》作业(20170904)
作业1(类型-理论学习,上传ftp,截止日期9月20日) 1.请写出ASP.NET MVC的优点. 2.请写出默认项目模板中以下文件夹或文件的作用.App_Data文件夹.Content文件夹.Con ...
- Gruntjs提高生产力(二)
摆脱混乱的html文件中开发,拥有development与product模式是我们梦寐以求的. 我买的需求是: 1.产出一定格式的目录结构,以供日常开发使用,脚手架功能. 2.在开发模式环境中我们按照 ...
- word2016_添加标题和目录
标题 开始->标题(层级可选) 目录 引用->目录->自动目录
- Java 连接操作 Redis 出现错误
Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: java.n ...
- 伪基站,卒于5G——本质上是基于网络和UE辅助的伪基站检测,就是将相邻基站的CI、信号强度等信息通过测量报告上报给网络,网络结合网络拓扑、配置信息等相关数据,对所有数据进行综合分析,确认在某个区域中是否存在伪基站
伪基站,卒于5G from:https://www.huxiu.com/article/251252.html?h_s=h8 2018-07-05 21:58收藏27评论6社交通讯 本文来自微 ...
- Roman Numeral Converter
将给定的数字转换成罗马数字. 所有返回的 罗马数字 都应该是大写形式. 这是一些对你有帮助的资源: Roman Numerals Array.splice() Array.indexOf() Arra ...
- Angular开发实践(七): 跨平台操作DOM及渲染器Renderer2
在<Angular开发实践(六):服务端渲染>这篇文章的最后,我们也提到了在服务端渲染中需要牢记的几件事件,其中就包括不要使用window. document. navigator等浏览器 ...
- New Concept English there (1)Typing speed exercise
Today,I start learn new concept english there,Mainly for listening practice and typing speed exercis ...
- New Concept English three (22)
34w 54 Some plays are so successful that they run for years on end. In many ways, this is unfortunat ...