解決數字驗證碼及執行錯誤

2022-08-24 23:39:11 字數 1133 閱讀 7135

traceback (most recent call last):

file "d:/pycharmprojects/net.bjxueche/coreimage.py", line 82, in text = image_to_string(image=image, boxes=true)

file "d:\mysoft\python\python35\lib\site-packages\pytesseract\pytesseract.py", line 162, in image_to_string

config=config)

file "d:\mysoft\python\python35\lib\site-packages\pytesseract\pytesseract.py", line 95, in run_tesseract

stderr=subprocess.pipe)

file "d:\mysoft\python\python35\lib\subprocess.py", line 950, in __init__

restore_signals, start_new_session)

file "d:\mysoft\python\python35\lib\subprocess.py", line 1220, in _execute_child

startupinfo)

filenotfounderror: [winerror 2] 系統找不到指定的檔案。

解決辦法:

開啟檔案 pytesseract.py,找到如下**,將tesseract_cmd的值修改為全路徑,在此使用就不會報錯了。

# change this if tesseract is not in your path, or is named differently

# tesseract_cmd = 'tesseract'

tesseract_cmd = 'c:/program files (x86)/tesseract-ocr/tesseract.exe'

ps:我的環境變數中明明有這個值,在cmd中也可以正常使用「tesseract」命令,不知道pytesseract為什麼會報錯,總之,這樣修改後可以正常執行了

數字驗證碼

private void picturebox1 click object sender,eventargs e 將str賦值給strcode,用於判斷輸入的驗證碼是否正確 strcode str 定義bmp影象的寬度等於picture的寬度減去5 int bmpwidth picturebox1....

案例字母數字驗證碼並驗證驗證碼

public.js 獲取id function id id 獲取某個範圍之間的隨機整數 function getrand startnum,endnum 隨機獲取六位十六進製制顏色值 function getrandcolor console.log str return str 隨機獲取num位數...

數字驗證碼的實現

public partial class validatecode system.web.ui.page 定義變數 private int codelen 4 驗證碼長度 private int fineness 85 清晰度 private int imgwidth 58 private int ...