必须要的依赖:apt install unrar
from rarfile import RarFile
io_buffer = io.BytesIO(response.body)
with RarFile(io_buffer) as fs:
for each in fs.infolist():
content = ""
bytes_info = b''
for i in range(0, 2):
try:
bytes_info = fs.open(each, pwd=f"{i}").read()
break
except Exception:
log_error(f"parse_file_error:{traceback.format_exc()}")
try:
content = bytes_info.decode("utf-8")
except Exception:
content = bytes_info.decode("gb18030")
标签:解压,info,fs,python,bytes,content,rar,io
From: https://www.cnblogs.com/c-x-a/p/18113225