Python-02.随机验证

 1 import random
 2 temp = ''
 3 for i in range(6):
 4     num = random.randrange(0,4)
 5     if num ==3 or num == 1:
 6         rad1 = random.randrange(0,10)
 7         temp = temp + str(rad1)
 8     else:
 9         rad2 = random.randrange(65, 91)
10         rad3 = chr(rad2)
11         temp = temp + rad3
12 print temp

随机生成六位数字字母混合的验证码。

posted @ 2016-10-24 21:32  那支歌  阅读(67)  评论(0)    收藏  举报