import random随机生成验证码

 1 #!/usr/bin/env python
 2 import random
 3 temp = ""
 4 for i in range(6):
 5     num = random.randrange(0, 4)
 6     if num == 3 or num == 1:
 7         ret1 = random.randrange(0, 10)
 8         temp = temp + str(ret1)
 9     else:
10         ret = random.randrange(65,91)
11         c1 = chr(ret)
12         temp = temp + c1
13 print(temp)

 

posted @ 2017-01-30 17:24  失落的黎明  阅读(212)  评论(0编辑  收藏  举报