程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Simple verification code processing with Python

編輯:Python

Catalog

preface

Environment module

Code display

Complete code

preface

When we collect data , Too fast or frequently visited , Or you can pop up the verification code as soon as you visit , And then the clam bead ~

Today, I will give you a simple method to deal with the verification code

Environment module

There needs to be a ddddocr modular , This is something that someone else has written open source , Simple and easy to use , But the accuracy is a little poor , But it is still very easy to use .

If you want precision , You can call some written by others API .

Let's just win+r Enter... After the search box pops up cmd , Click OK to pop up the command prompt window , Input pip install ddddocr You can install .

If not, please refer to my top article for detailed explanation .

Code display

Not much code , It's simple .

After the module is installed, let's import it :

import ddddocr

Then instantiate , Use one cor Receive this data .

ocr = ddddocr.DdddOcr()

I have prepared four verification codes here :

First of all, we use with open To read this file , The read mode uses rb , If it is a picture, read its binary data

with open('img_3.png', 'rb') as f:

Use f.read() Read the data out , Then customize a variable to receive .

img_bytes = f.read()

And then we passed classification Pass it in , Just print out the results .

result = ocr.classification(img_bytes)print(result)

Realization effect :

Pure digital

Letter + Digital

You can see that they are completely identified , Even if there are some fancy horizontal lines on it .

Complete code import ddddocrocr = ddddocr.DdddOcr()with open('img_3.png', 'rb') as f: img_bytes = f.read()result = ocr.classification(img_bytes)print(result)

You can try it yourself , It can also be directly applied to the practice of data collection ~

This is about using Python This is the end of the article on simple verification code processing , More about Python For the content of verification code processing, please search the previous articles of software development network or continue to browse the relevant articles below. I hope you can support software development network more in the future !



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved