生成图像验证码的库。
wsy_captcha的Python项目详细描述
睡衣验证码
===================
生成图像验证码的库。
…图片::https://raw.githubusercontent.com/wushuyi/wsy_captcha/master/test.png
安装
----
使用pip:安装wsy_captcha:
$pip安装wsy_captcha
基本用法
----
…代码::python
来自wsy_captcha.comp导入打印_
来自wsy_captcha.captcha导入captcha
验证码=验证码()
code=captcha.randomcode()
打印(代码)
captcha.write(代码“test.png”)
高级使用
----
…代码::python
来自wsy_captcha.comp导入打印_
来自wsy_captcha.captcha导入captcha
将wsy_captcha.image导入为图像
MyCaptcha类(验证码):
def生成映像(self,chars):
文本图形=[
image.warp(),
image.rotate(),
图像.offset(),
fn=图像。验证码(
图纸=[
图像.背景(颜色='ffffff'),
image.text(字体=自身字体,图形=文本图形)
图像曲线(宽度=2)
图像曲线(宽度=2)
图像曲线(宽度=2)
图像噪声(数字=60,颜色=5C87B2,电平=2)
image.smooth(),
,
宽度=自身宽度,
高度=自身高度,
)
返回fn(字符)
验证码=我的验证码()
code=captcha.randomcode()
img=验证码生成(代码)
打印(代码)
f=打开('test.png','wb')
f.write(img.read())
关闭()
===================
生成图像验证码的库。
…图片::https://raw.githubusercontent.com/wushuyi/wsy_captcha/master/test.png
安装
----
使用pip:安装wsy_captcha:
$pip安装wsy_captcha
基本用法
----
…代码::python
来自wsy_captcha.comp导入打印_
来自wsy_captcha.captcha导入captcha
验证码=验证码()
code=captcha.randomcode()
打印(代码)
captcha.write(代码“test.png”)
高级使用
----
…代码::python
来自wsy_captcha.comp导入打印_
来自wsy_captcha.captcha导入captcha
将wsy_captcha.image导入为图像
MyCaptcha类(验证码):
def生成映像(self,chars):
文本图形=[
image.warp(),
image.rotate(),
图像.offset(),
fn=图像。验证码(
图纸=[
图像.背景(颜色='ffffff'),
image.text(字体=自身字体,图形=文本图形)
图像曲线(宽度=2)
图像曲线(宽度=2)
图像曲线(宽度=2)
图像噪声(数字=60,颜色=5C87B2,电平=2)
image.smooth(),
,
宽度=自身宽度,
高度=自身高度,
)
返回fn(字符)
验证码=我的验证码()
code=captcha.randomcode()
img=验证码生成(代码)
打印(代码)
f=打开('test.png','wb')
f.write(img.read())
关闭()