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