Python题目:生成100个随机不重复的字符串【杭州多测师】【杭州多测师_王sir】

import random,string

def verify():
    '''
    生成100个随机不重复的字符串
    :return:
    '''
    list1=[]
    new_list=[]
    while 1:
        value = ''.join(random.sample(string.ascii_letters+string.digits,6))  #生成6位数随机验证码
        if value not in new_list:
            new_list.append(value)
            if len(new_list)==100:
                break
        else:
            continue
    print(new_list,len(new_list))

if __name__ == '__main__':
    verify()
原文地址:https://www.cnblogs.com/xiaoshubass/p/15123784.html