random实现验证码
1 import random 2 # c = [] 3 # for i in range(5): 4 # a = random.randint(0,9) 5 # b = chr(random.randint(65,90)) 6 # c.append(random.choice((a,b))) 7 # print(c, end='') 8 9 # 2 10 11 # c = [] 12 # for i in range(5): 13 # a = random.randint(0,9) 14 # b = chr(random.randint(65,90)) 15 # c.append(random.choice((a,b))) 16 # s = '' 17 # for j in c: 18 # s += str(j) 19 # print(s) 20 21 # 3 chr(30)----返回的是字符串 22 s = '' 23 for i in range(5): 24 a = random.randint(0,9) 25 b = chr(random.randint(65,90)) 26 c = str(random.choice((a,b))) 27 s += c 28 print(s)
为什么要坚持,想一想当初!