TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple'报错解决方案
一、问题描述
执行以下代码报错
#!/usr/local/bin/python3.7
from PIL import Image
import pytesseract
# 打开图片
img = Image.open('Reptile/code.png')
# 识别图片
result = pytesseract.image_to_string(img)
print(result)
二、出现问题原因
图片模式有问题。
三、解决方案
将图片模式改为RGB,即增加如下代码:
img = img.convert('RGB')
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步