python 学习之用random生成验证码

import random

code = []
for i in range(6):
    if  i == random.randint(1,5):
        code.append(str(random.randint(0,9)))
    else:
        temp = random.randint(65,90)
        code.append(chr(temp))
print ''.join(code)

 

posted @ 2016-08-02 09:11  vxee  阅读(165)  评论(0编辑  收藏  举报