当前位置: 移动技术网 > IT编程>脚本编程>Python > python之验证码生成(gvcode与captcha)

python之验证码生成(gvcode与captcha)

2019年06月12日  | 移动技术网IT编程  | 我要评论

韩剧城市猎人吧,哪种取暖器效果好,人生遥控器迅雷下载

今天向大家总结一下python在做项目时用到的验证码生成工具:gvcode与captcha

gvcode

全称:graphic-verification-code

安装:

pip install gvcode

使用:

import gvcode

s, v = gvcode.generate()  #序列解包

s.show()  #显示生成的验证码图片

print(v)  #打印验证码字符串

效果:

captcha

安装:

pip install captcha

使用:

from captcha.image import imagecaptcha
from random import randint
list = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
    '', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
chars = ''
for i in range(4):
  chars += list[randint(0, 62)]
image = imagecaptcha().generate_image(chars)

image.show()

效果:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网