unzip

How can unrar a file with python

一世执手 提交于 2019-11-26 18:31:23
问题 I can to unzip a file if file is a .zip and unrar file if my file type is .rar . How i can do this work with python 2.7? 回答1: Try the pyunpack package: from pyunpack import Archive Archive('a.zip').extractall('/path/to') 回答2: Late, but I wasn't satisfied with any of the answers. pip install patool import patoolib patoolib.extract_archive("foo_bar.rar", outdir="path here") Works on Windows and linux without any other libraries needed. 回答3: A good package for it is rarfile : Infos and docs here

【Linux】war包的解压与压缩

て烟熏妆下的殇ゞ 提交于 2019-11-26 18:25:55
网上很多人说用jar包解压,但jar命令解压时不能指定目录,推荐使用unzip解压war包。 unzip -d 指定目录 [root@oracle upload]# unzip -oq common.war -d common 命令名: unzip 功 能说明:解压缩zip文 件 语  法:unzip [-cflptuvz][-agCjLMnoqsVX][-P <密 码>][.zip文 件][文件][-d <目录>][-x <文件>] 或 unzip [-Z] 补充说明:unzip为.zip压缩文件的解压缩程序。 参  数: -c 将 解压缩的结果显示到屏幕上,并对字符做适当的转换。 -f 更 新现有的文件。 -l 显 示压缩文件内所包含的文件。 -p 与-c参数类似,会将解压缩的结果显示到屏幕上,但不会执行任 何的转换。 -t 检 查压缩文件是否正确。,但不解压。 -u 与-f参数类似,但是除了更新现有的文件外,也会将压缩文件中 的其他文件解压缩到目录中。 -v 执 行是时显示详细的信息。或查看压缩文件目录,但不解压。 -z 仅 显示压缩文件的备注文字。 -a 对 文本文件进行必要的字符转换。 -b 不 要对文本文件进行字符转换。 -C 压 缩文件中的文件名称区分大小写。 -j 不 处理压缩文件中原有的目录路径。 -L 将 压缩文件中的全部文件名改为小写。 -M 将

How to speed up unzipping time in Java / Android?

北慕城南 提交于 2019-11-26 17:58:13
问题 Unzipping files on android seems to be dreadfully slow. At first I thought this was just the emulator but it appears to be the same on the phone. I've tried different compression levels, and eventually dropped down to storage mode but it still takes ages. Anyway, there must be a reason! Does anyone else have this problem? My unzip method looks like this: public void unzip() { try{ FileInputStream fin = new FileInputStream(zipFile); ZipInputStream zin = new ZipInputStream(fin); File rootfolder

Downloading and unzipping a .zip file without writing to disk

烂漫一生 提交于 2019-11-26 17:57:35
问题 I have managed to get my first python script to work which downloads a list of .ZIP files from a URL and then proceeds to extract the ZIP files and writes them to disk. I am now at a loss to achieve the next step. My primary goal is to download and extract the zip file and pass the contents (CSV data) via a TCP stream. I would prefer not to actually write any of the zip or extracted files to disk if I could get away with it. Here is my current script which works but unfortunately has to write

Unpack inner zips in zip with Maven

假如想象 提交于 2019-11-26 17:40:11
问题 I can unpack zip file via the maven-dependency plugin, but currently I have the problem that inside that zip file other zip files are include and I need to unpack them as well. How can I do this? 回答1: You can unzip any files using ant task runner plugin: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>prepare</id> <phase>validate</phase> <configuration> <tasks> <echo message="prepare phase" /

Unzipping and the * operator

橙三吉。 提交于 2019-11-26 17:31:59
The python docs gives this code as the reverse operation of zip: >>> x2, y2 = zip(*zipped) In particular "zip() in conjunction with the * operator can be used to unzip a list". Can someone explain to me how the * operator works in this case? As far as I understand, * is a binary operator and can be used for multiplication or shallow copy...neither of which seems to be the case here. When used like this, the * (asterisk, also know in some circles as the "splat" operator) is a signal to unpack arguments from a list. See http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists

download and unzip file in iOS

ε祈祈猫儿з 提交于 2019-11-26 17:30:26
I want to download a zip file contains a folder with a lot of file audios which use for my pronunciation in dictionary. I use ASIHTTPRequest to download it and my problem is "I don't know how to unzip that file". I tried to use SSZipArchive and ZipArchive both of them is based on minizip but I got error when I compile code Undefined symbols for architecture i386: "_OBJC_CLASS_$_ZipArchive", referenced from: objc-class-ref in AppDelegate.o . So could you give me some advices I've used ZipArchive with success in the past. It's pretty ligthweight and simple to use, supports password protection,

压缩&解压缩

ε祈祈猫儿з 提交于 2019-11-26 17:13:10
1、zip,unzip zip 压缩文件名.zip 要被压缩文件的名字 zip -m test1.zip test2.txt 把test2添加到test1.zip zip -d test1.zip test2.txt 把test2从test1.zip中删除 zip test1.zip *.txt -x test10.txt 除test10以外,将所有.txt文件压缩 zip -r /dir 递归压缩 unzip test1.txt unzip test1.zip -d /压缩目录 unzip -v test1.zip 不解压,查看压缩内容 2、gzip、gunzip gzip 被压缩的文件名,压缩后,源文件不保留 gzip -c test.txt > test.txt.gz 压缩,保留源文件 gzip -r 目录 压缩了目录下的所有内容 gunzip test.txt.gz gunzip -c test.zip.gz > /root/test.txt 解压缩到特定目录,并且保留源文件 不解压查看 [root@localhost test1]#zcat test5.txt.gz [root@locaIhost test1]#zless test5.txt.gz 3、bzip2、bunzip2 bzip2 被压缩的文件名,压缩后,源文件不保留 bzip2 -c test.txt >

【转】linux解压zip和rar

无人久伴 提交于 2019-11-26 16:26:33
1)对于.zip linux下提供了zip和unzip程序,只需yum install unzip即可,zip是压缩程序,unzip是解压程序。它们的参数选项很多,这里只做简单介绍,依旧举例说明一下其用法: ? 1 # zip all.zip *.jpg 这条命令是将所有.jpg的文件压缩成一个zip包 ? 1 # unzip all.zip 这条命令是将all.zip中的所有文件解压出来 2)对于.rar 要在linux下处理.rar文件,需要安装RAR for Linux,可以从网上下载,但要记住,RAR for Linux 不是免费的;可从http://www.rarsoft.com/download.htm下载RARfor Linux 3.2. 0,然后安装: 链接:https://pan.baidu.com/s/1ECj46FDW8R6yQpQXjKy6LA 提取码:p61s ? 1 2 3 # tar -xzpvf rarlinux-3.2.0.tar.gz # cd rar # make 这样就安装好了,安装后就有了rar和unrar这两个程序,rar是压缩程序,unrar 是解压程序。它们的参数选项很多,这里只做简单介绍,依旧举例说明一下其用法: ? 1 # rar a all *.jpg 这条命令是将所有.jpg的文件压缩成一个rar包,名为all.rar

Unzipping files in Python

混江龙づ霸主 提交于 2019-11-26 15:34:38
I read through the zipfile documentation , but couldn't understand how to unzip a file, only how to zip a file. How do I unzip all the contents of a zip file into the same directory? Rahul import zipfile with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref: zip_ref.extractall(directory_to_extract_to) That's pretty much it! user1741137 If you are using Python 3.2 or later: import zipfile with zipfile.ZipFile("file.zip","r") as zip_ref: zip_ref.extractall("targetdir") You dont need to use the close or try/catch with this as it uses the context manager construction. Use the extractall method,