首页 > QQ浏览器手机版乱码文件名提取特征码并批量转码

QQ浏览器手机版乱码文件名提取特征码并批量转码

来源:Chrome浏览器官网 时间:2026-07-21

QQ浏览器手机版乱码文件名提取特征码并批量转码1

要提取QQ浏览器手机版乱码文件名并批量转码,可以使用Python的正则表达式库`re`和`pytesseract`库。首先需要安装这两个库:
bash
pip install re pytesseract

然后使用以下代码:
python
import re
from PIL import Image
import pytesseract
def extract_filename(image_path):
image = Image.open(image_path)
text = image._gettext()
return re.findall(r'[^\x00-\x7F]+', text)[0]
def batch_convert_to_utf8(file_list):
for file_path in file_list:
with open(file_path, 'rb') as f:
text = f.read()
converted_text = text.decode('utf-8')
new_file_path = file_path.replace(file_path, converted_text)
with open(new_file_path, 'wb') as f:
f.write(text)
if __name__ == '__main__':
file_list = ['file1.jpg', 'file2.jpg'] 替换为实际的文件路径列表
batch_convert_to_utf8(file_list)

这段代码首先定义了一个`extract_filename`函数,用于从图片中提取文件名。然后定义了一个`batch_convert_to_utf8`函数,用于将文件名转换为UTF-8编码。最后在主函数中调用这两个函数,将乱码文件名提取特征码并批量转码。
TOP