当前位置:网站首页>Generate verification code
Generate verification code
2022-04-23 17:58:00 【Feng Ye 520】
from captcha.image import ImageCaptcha
import random
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
number = ['0','1','2','3','4','5','6','7','8','9']
ALPH = []
alph = []
for i in range(65,91):
ALPH.append(chr(i))
for i in ALPH:
alph.append(i.swapcase())
def random_captcha_text(size=4,charset=number+alph+ALPH):
captcha_text = []
for i in range(size):
c = random.choice(charset)
captcha_text.append(c)
return captcha_text
def gen_captcha_image():
image = ImageCaptcha()
captcha_text = random_captcha_text()
captcha_text = ''.join(captcha_text)
captchaInfo = image.generate(captcha_text)
# print(captchaInfo)
captcha_image = Image.open(captchaInfo)
captcha_image = np.array(captcha_image)
return captcha_text,captcha_image
if __name__ == '__main__':
text, image = gen_captcha_image()
print(text)
# print(image)
f = plt.figure()
ax = f.add_subplot(111)
ax.text(0.1, 0.9, text, ha='center',va='center')
plt.imshow(image)
plt.show()
版权声明
本文为[Feng Ye 520]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230546152207.html
边栏推荐
- cartographer_ There is no problem compiling node, but running the bug that hangs directly
- Go语言JSON包使用
- [appium] write scripts by designing Keyword Driven files
- Halo open source project learning (II): entity classes and data tables
- 编译原理 求first集 follow集 select集预测分析表 判断符号串是否符合文法定义(有源码!!!)
- Special effects case collection: mouse planet small tail
- SystemVerilog (VI) - variable
- 2022年流动式起重机司机国家题库模拟考试平台操作
- Eigen learning summary
- .104History
猜你喜欢
MySQL_01_简单数据检索
Applet learning notes (I)
Summary of floating point double precision, single precision and half precision knowledge
Gaode map search, drag and drop query address
Element calculation distance and event object
440. The k-th small number of dictionary order (difficult) - dictionary tree - number node - byte skipping high-frequency question
Cross domain settings of Chrome browser -- including new and old versions
C1小笔记【任务训练篇二】
JS parsing and execution process
Theory and practice of laser slam in dark blue College - Chapter 2 (odometer calibration)
随机推荐
Halo 开源项目学习(二):实体类与数据表
undefined reference to `Nabo::NearestNeighbourSearch
Notes on common basic usage of eigen Library
JS interview question: FN call. call. call. Call (FN2) parsing
String function in MySQL
Add drag and drop function to El dialog
[binary number] maximum depth of binary tree + maximum depth of n-ary tree
C# 的数据流加密与解密
Data stream encryption and decryption of C
2022 tea artist (primary) examination simulated 100 questions and simulated examination
Type judgment in [untitled] JS
587. Install fence / Sword finger offer II 014 Anagrams in strings
Comparison between xtask and kotlin coroutine
开源按键组件Multi_Button的使用,含测试工程
JS forms the items with the same name in the array object into the same array according to the name
Amount input box, used for recharge and withdrawal
31. Next arrangement
ES6 face test questions (reference documents)
2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
2022 Shanghai safety officer C certificate operation certificate examination question bank and simulation examination