Home  >  Article  >  Backend Development  >  How to decompress rar files in python

How to decompress rar files in python

尚
Original
2019-07-06 11:20:0610574browse

How to decompress rar files in python

由于rar通常为window下使用,须要额外的Python包rarfile。

可用地址: http://sourceforge.net/projects/rarfile.berlios/files/rarfile-2.4.tar.gz/download
解压到Python安装文件夹的/Scripts/文件夹下,在当前窗体打开命令行,输入Python setup.py install

安装完毕。

实现解压方法:

#coding=utf-8
import rarfile
path = "E:\\New\\New.rar"
path2 = "E:\\New"
 
rf = rarfile.RarFile(path)         #待解压文件
rf.extractall(path2)               #解压指定文件路径

更多Python相关技术文章,请访问Python教程栏目进行学习!

The above is the detailed content of How to decompress rar files in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn