Python生成验证码的框架
Project description
zdppy_captcha
python用于生成图片,声音等验证码的底层框架
安装
pip install zdppy-captcha
使用教程
显示图片验证码
# 生成图片验证码
import random
from zdppy_captcha.image import ImageCaptcha
# 生成随机字符串
code = random.sample('abcdefghijklmnopqrstuvwxyz1234567890', 4) # 随机选取4个不重复字符串,返回一个列表
# 生成图片验证码对象
image = ImageCaptcha()
# 第一种使用方式:生成图片验证码
im = image.generate_image(code)
im.show() # 可以直接展示图片
保存验证码图片
# 生成图片验证码
import random
from zdppy_captcha.image import ImageCaptcha
# 生成随机字符串
code = random.sample('abcdefghijklmnopqrstuvwxyz1234567890', 4) # 随机选取4个不重复字符串,返回一个列表
# 生成图片验证码对象
image = ImageCaptcha()
# 第二种使用方式:生成图片验证码并保存
image.write(code, 'zdppy_captcha.jpg')
将验证码转换为bytesio
# 生成图片验证码
import random
from zdppy_captcha.image import ImageCaptcha
# 生成随机字符串
code = random.sample('abcdefghijklmnopqrstuvwxyz1234567890', 4) # 随机选取4个不重复字符串,返回一个列表
# 生成图片验证码对象
image = ImageCaptcha()
# 第三种使用方式:生成图片验证码BytesIO
data = image.generate(code)
print(data, type(data))
生成base64图片
import zdppy_captcha as captcha
# 获取验证码以及base64图片
code, img = captcha.get_base64(6)
print(code)
print(img)
版本历史
v0.1.0
- 基本用法
v0.1.2
- get_base64生成key,code和img
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zdppy_captcha-0.1.2.tar.gz
(104.3 kB
view details)
Built Distribution
zdppy_captcha-0.1.2-py3-none-any.whl
(106.6 kB
view details)
File details
Details for the file zdppy_captcha-0.1.2.tar.gz
.
File metadata
- Download URL: zdppy_captcha-0.1.2.tar.gz
- Upload date:
- Size: 104.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9285ac69bc207cf8b2ca0943c108fef135212f428649cd5961c793b485b1476f |
|
MD5 | f33fbcfc446554c839eaa359eb033966 |
|
BLAKE2b-256 | 5b9c3bdc4c44a9aff42a29da45761f8b7cbca5e97739b655b2eb51ad30f58903 |
File details
Details for the file zdppy_captcha-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: zdppy_captcha-0.1.2-py3-none-any.whl
- Upload date:
- Size: 106.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7509da0d086c3c78e62c25a73b413c633f6940949f7997461162340b120e7639 |
|
MD5 | 8e4affc82b717c5de2f70bfbc3299406 |
|
BLAKE2b-256 | 67df58bd106a4fd35b1e828db7c1b479d72d66d80b23153429033722ef29a789 |