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')
  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM