资源简介
python生成扭曲带干扰验证码,主要用于做训练集,可自行配置字体,干扰线数
代码片段和文件信息
import random
import string
import sys
import math
from PIL import ImageImageDrawImageFontImageFilter
#===该程序的目录===
filename=“D:/“
typen=2
typet=[
“arialbd.ttf“
“corbelb.ttf“
]
#字体的位置
font_path = “C:/Windows/Fonts/“
#生成几位数的验证码
#生成验证码图片的高度和宽度
size = (180180)
#用来绘制干扰线
def gene_line(draw):
py = random.randint(0 3)
begin = (-py*50 random.randint(0 100))
end = (200-py*50 random.randint(0 100))
draw.line([begin end] fill = 0width=5)
#生成验证码
def gene_code():
widthheight = size #宽和高
image = Image.new(‘1‘(widthheight)1) #创建图片
font = ImageFont.truetype(font_path+typet[random.randint(0 typen-1)]70) #验证码的字体
draw = ImageDraw.Draw(image) #创建画笔
source = [‘0‘‘1‘‘2‘‘3‘‘4‘‘5‘‘6‘‘
相关资源
- Python-BDD100K大规模多样化驾驶视频数据
- Instant Pygame for Python Game Development How
- Biopython Tutorial
- Think Python 2nd
- 一个小小的表白程序(python)
- Python课堂笔记(高淇400集第一季)
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
评论
共有 条评论