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()

 

posted @ 2021-08-10 14:50  多测师_树哥  阅读(482)  评论(0编辑  收藏  举报