【Python】window10 python rarfile

rarfile is a third-party library. Need to install the third-party library rarfile

pip install rarfile

 

Use rarfile to decompress the corresponding rar file

import rarfile
path = r'C:\Users\zhengruiping\py_operate_ftp\test_ftp_data\t'
os.chdir(path)
rf = rarfile.RarFile('20191030.rar')
rf.extractall(path)
rf.close()

Running the above code will report an error. The error is as follows:

The reason is: the file UnRAR.exe is missing in the execution directory of python

 

Solution: Search for the file UnRAR.exe in the computer. And put it in the execution directory of python. Mine is: C:\ProgramData\Anaconda3\

Run the above code again. solve! ! !

 

Guess you like

Origin blog.csdn.net/xiezhen_zheng/article/details/103035245