当前位置:网站首页>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
边栏推荐
- C1小笔记【任务训练篇二】
- ROS package NMEA_ navsat_ Driver reads GPS and Beidou Positioning Information Notes
- ES6 new method
- I / O multiplexing and its related details
- In JS, t, = > Analysis of
- Add drag and drop function to El dialog
- MySQL进阶之索引【分类,性能分析,使用,设计原则】
- Data stream encryption and decryption of C
- undefined reference to `Nabo::NearestNeighbourSearch
- MySQL advanced index [classification, performance analysis, use, design principles]
猜你喜欢

MySQL 中的字符串函数

Chrome浏览器的跨域设置----包含新老版本两种设置

k8s之实现redis一主多从动态扩缩容

Nat commun | current progress and open challenges of applied deep learning in Bioscience

Anchor location - how to set the distance between the anchor and the top of the page. The anchor is located and offset from the top

JS get link? The following parameter name or value, according to the URL? Judge the parameters after

C# 网络相关操作

Uniapp custom search box adaptation applet alignment capsule

JS forms the items with the same name in the array object into the same array according to the name

The ultimate experience, the audio and video technology behind the tiktok
随机推荐
2022江西储能技术展会,中国电池展,动力电池展,燃料电池展
Build openstack platform
.105Location
Go语言JSON包使用
MySQL进阶学习之SQL优化【插入,主键,排序,分组,分页,计数】
YOLOv4剪枝【附代码】
.105Location
2022 tea artist (primary) examination simulated 100 questions and simulated examination
Anchor location - how to set the distance between the anchor and the top of the page. The anchor is located and offset from the top
关于gcc输出typeid完整名的方法
Element calculation distance and event object
ES6 face test questions (reference documents)
纳米技术+AI赋能蛋白质组学|珞米生命科技完成近千万美元融资
Data stream encryption and decryption of C
Summary of common server error codes
Laser slam theory and practice of dark blue College Chapter 3 laser radar distortion removal exercise
C network related operations
An example of linear regression based on tensorflow
Add drag and drop function to El dialog
Some questions some questions some questions some questions