输出一个六位的随机验证码
1 import random 2 a=['0','1','2','3','4','5','6','7','8','9',\ 3 'A','B','C','D','E','F','G','H','I','J','K','L',\ 4 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'\ 5 'a','b','c','d','e','f','g','h','i','j','k','l',\ 6 'm','n','o','p','q','r','s','t','u','v','w','x','y','z'] 7 list1=[] 8 for i in range(6): 9 ran_list=random.sample(a,1)#生成一个随机码,输出为列表格式 10 ran_str=''.join(ran_list)#转化为字符串格式 11 list1.append(ran_str)#循环追加成为6位,输出为列表格式 12 random1=''.join(list1)#转化为字符串格式 13 print(random1)#打印