运维网's Archiver
论坛
›
Python
› 使用Python生成随机简单的验证码
233123
发表于 2016-5-19 08:49:24
使用Python生成随机简单的验证码
简单的生成验证码
import random
code = []
for i in range(5):
if i == random.randint(1,9):#随机生成1-9的数字
code.append(str(random.randint(1,9)))
else:
temp = random.randint(65,90)
code.append(chr(temp))#随机生成A-Z的字母
print ''.join(code)
页:
[1]
查看完整版本:
使用Python生成随机简单的验证码