需求:
随机生成6位的验证码,要求有字母和数字
import random temp = "" for i in range(6): j = random.randrange(0,2) if j = 0: rand1 = random.randrange(0,10) temp += str(rand1) else: rand2 = random.randrange(65,91) temp += chr(rand2) print(temp)
随机生成6位的验证码,要求有字母和数字
import random temp = "" for i in range(6): j = random.randrange(0,2) if j = 0: rand1 = random.randrange(0,10) temp += str(rand1) else: rand2 = random.randrange(65,91) temp += chr(rand2) print(temp)