python 生成图形验证码的库captcha

pip install captcha

官网

from captcha.audio import AudioCaptcha
from captcha.image import ImageCaptcha

image = ImageCaptcha()
data = image.generate('1234')

base64_string = base64.b64encode(data.getvalue()).decode('utf-8') # 转成base64编码给前端

image.write('1234', 'out.png') # 保存本地

# 还有声音验证码,只不过是英文的
audio = AudioCaptcha()
data = audio.generate('1234')
audio.write('1234', 'out.wav')


你可能感兴趣的:(python)