如何用python解压文件 [英] How can unrar a file with python
本文介绍了如何用python解压文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果文件是.zip
,我可以解压缩文件,如果我的文件类型是.rar
,我可以解压缩文件.我如何使用 python 2.7 完成这项工作?
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?
推荐答案
迟到了,但我对任何答案都不满意.
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")
适用于 Windows 和 linux,无需任何其他库.
Works on Windows and linux without any other libraries needed.
这篇关于如何用python解压文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文