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)
原文地址:https://www.cnblogs.com/shiluoliming/p/6358196.html