国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Python:IOError:imagefileistruncated的解決辦法

2019-11-14 17:16:11
字體:
供稿:網(wǎng)友

代碼如下:

#coding:utf-8from PIL import Imageimport pytesseractdef test():    im = Image.open(r"pic.gif")    vcode = pytesseract.image_to_string(im)    PRint vcode

執(zhí)行以上代碼進(jìn)行簡單驗(yàn)證碼識(shí)別的時(shí)候會(huì)拋出一個(gè)異常:

Traceback (most recent call last):  File "D:/test/vcode.py", line 15, in <module>    main()  File "D:/test/vcode.py", line 9, in main    test()  File "D:/test/test.py", line 8, in test    vcode = pytesseract.image_to_string(im)  File "build/bdist.win32/egg/pytesseract/pytesseract.py", line 143, in image_to_string  File "D:/Program Files (x86)/Python/Python27/lib/site-packages/PIL/Image.py", line 1749, in split    self.load()  File "D:/Program Files (x86)/Python/Python27/lib/site-packages/PIL/ImageFile.py", line 232, in load    "(%d bytes not processed)" % len(b))IOError: image file is truncated (5 bytes not processed)

解決辦法是,再添加如下2句代碼:

from PIL import ImageFileImageFile.LOAD_TRUNCATED_IMAGES = True

最終,完整的代碼如下:

#coding:utf-8from PIL import Imageimport pytesseractfrom PIL import ImageFileImageFile.LOAD_TRUNCATED_IMAGES = Truedef test():    im = Image.open(r"pic.gif")    vcode = pytesseract.image_to_string(im)    print vcode

相關(guān)文章:

關(guān)于利用python進(jìn)行驗(yàn)證碼識(shí)別的一些想法:http://m.survivalescaperooms.com/xiaowuyi/archive/2012/09/10/2675286.html

python利用pytesser模塊實(shí)現(xiàn)圖片文字識(shí)別:http://www.jinglingshu.org/?p=9281

驗(yàn)證碼圖片字符識(shí)別兩種python實(shí)現(xiàn)方法:http://vipscu.blog.163.com/blog/static/18180837220134234528457/

python模擬登陸登陸一:驗(yàn)證碼與cookies的同步處理思路:http://www.dabu.info/python-login-crawler-captcha-cookies.html

原文地址:http://m.survivalescaperooms.com/hongfei/p/4436767.html


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 镇沅| 苏尼特左旗| 郸城县| 盐城市| 津南区| 崇礼县| 沂源县| 凤山县| 滕州市| 石柱| 海原县| 盘锦市| 会昌县| 永嘉县| 定远县| 巴塘县| 铁岭县| 高碑店市| 雷波县| 五原县| 哈巴河县| 沾化县| 迁西县| 韶山市| 正宁县| 南岸区| 德格县| 屏东市| 元朗区| 韶关市| 张掖市| 徐水县| 昌乐县| 富裕县| 南汇区| 涪陵区| 台中市| 湘乡市| 常州市| 灵台县| 鸡西市|