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
v0.1.3
- 新增zdppy_api.get方法
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.3.tar.gz
(104.4 kB
view details)
Built Distribution
zdppy_captcha-0.1.3-py3-none-any.whl
(106.8 kB
view details)
File details
Details for the file zdppy_captcha-0.1.3.tar.gz
.
File metadata
- Download URL: zdppy_captcha-0.1.3.tar.gz
- Upload date:
- Size: 104.4 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 | 6fe07d81518e1b4e9ef2201037302a28bf06e8907b37bf4738bd093a6dce8321 |
|
MD5 | cafc6971663662f5e93eab8b2b4bbaff |
|
BLAKE2b-256 | c7565ffeacf0c20d5e2686e9da533c29ee16397804079872ad9f0ce53518fc2e |
File details
Details for the file zdppy_captcha-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: zdppy_captcha-0.1.3-py3-none-any.whl
- Upload date:
- Size: 106.8 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 | 192ae0b8d5dc02aee074423c620626d1b51c793265df0e87616e6bfcf013f7c3 |
|
MD5 | 798046b2f349c5026195cfd629f14019 |
|
BLAKE2b-256 | 5425bcf36bfc4def9bbf2e377f9c3a36471be1ff8194306fcc59720252ba73ee |