基于random实现随机验证码
1 import random 2 3 i = 0 4 s = '' 5 while i < 5: 6 7 num = random.randint(0,9) 8 alp = chr(random.randint(65,90)) 9 add = str(random.choice([num,alp])) 10 s += add 11 i += 1 12 print(s) 13 14 15 ------------------------------------------------------------------------- 16 import random 17 18 code = '' 19 for i in range(5): 20 num=random.randint(0,9) 21 alf=chr(random.randint(65,90)) 22 add=random.choice([num,alf]) 23 code += str(add) 24 print(code)
为什么要坚持,想一想当初!