python生成验证码
2017-12-01 01:25
218 查看
#!/usr/bin/python #coding=utf-8 #引入模块 import random temp='' count=0 #循环6次,每次生成一个字符 for i in range(6): #这里的随机数和下面进行对比,如果对比成功则生成一个数字,这样数字就是随机出现。 r=random.randrange(1, 6) if r==2 or r==4: #生成的数字要转换成字符 temp=temp+str(random.randrange(0,10)) else: a=random.randrange(65, 90) temp=temp+chr(a) print(temp)
如下图生成一个6位的验证码:
相关文章推荐
- Python 随机生成中文验证码
- python生成验证码
- python生成网页验证码
- Python生成随机验证码的两种方法
- Python生成随机验证码的两种方法
- 利用Python生成随机4位验证码
- Python(4)-- 随机生成N位验证码的字符
- 第0010道练习题_Python生成验证码图片
- Python随机数生成验证码
- python图片验证码生成代码
- python代码生成验证码
- python PIL模块与随机生成中文验证码
- Python 随机生成中文验证码的实例代码
- python生成验证码
- 生成六位验证码python代码
- Python 随机生成中文验证码的实例代码
- python生成验证码
- PIL(Python Image Library)生成验证码
- day04_python random模块随机生成验证码
- 学习python:实例2.用PIL生成随机验证码