一、问题描述

  执行以下代码报错

  #!/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')
  

相关文章:

  • 2022-01-14
  • 2022-01-10
  • 2021-12-10
猜你喜欢
  • 2021-07-15
  • 2021-10-16
  • 2022-12-23
  • 2021-06-08
  • 2021-05-24
  • 2021-07-06
相关资源
相似解决方案