当前位置:网站首页>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
边栏推荐
- Compilation principle first set follow set select set prediction analysis table to judge whether the symbol string conforms to the grammar definition (with source code!!!)
- 2022年茶艺师(初级)考试模拟100题及模拟考试
- Go's gin framework learning
- MySQL advanced index [classification, performance analysis, use, design principles]
- Auto. JS custom dialog box
- Use of list - addition, deletion, modification and query
- 2022 Jiangxi energy storage technology exhibition, China Battery exhibition, power battery exhibition and fuel cell Exhibition
- Halo 开源项目学习(二):实体类与数据表
- Commonly used functions -- spineros:: and spineros::)
- MySQL进阶之索引【分类,性能分析,使用,设计原则】
猜你喜欢

【Appium】通过设计关键字驱动文件来编写脚本

Cloud native Virtualization: building edge computing instances based on kubevirt

Compilation principle first set follow set select set prediction analysis table to judge whether the symbol string conforms to the grammar definition (with source code!!!)

Remember using Ali Font Icon Library for the first time

高德地图搜索、拖拽 查询地址

1217_ Generating target files using scons

C#的随机数生成

Welcome to the markdown editor

干货 | 快速抽取缩略图是怎么练成的?

MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
随机推荐
Gets the time range of the current week
20222 return to the workplace
Go对文件操作
[appium] write scripts by designing Keyword Driven files
ROS package NMEA_ navsat_ Driver reads GPS and Beidou Positioning Information Notes
Write a regular
Romance in C language
How to read literature
Index: teach you index from zero basis to proficient use
2021 Great Wall Cup WP
QTableWidget使用讲解
Some questions some questions some questions some questions
_ FindText error
vite配置proxy代理解决跨域
An example of linear regression based on tensorflow
高德地图搜索、拖拽 查询地址
MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
Click Cancel to return to the previous page and modify the parameter value of the previous page, let pages = getcurrentpages() let prevpage = pages [pages. Length - 2] / / the data of the previous pag
587. 安装栅栏 / 剑指 Offer II 014. 字符串中的变位词
Sword finger offer 22 The penultimate node in the linked list - speed pointer