python生成特殊随机字符密码

import random
import string
n = 0;
while n<10:
    str_source = string.ascii_letters + string.digits + string.punctuation
    str_list = random.sample(str_source,10)
    special=['/','\\','@','I','l','o','O']
    if len(set(str_list) & set(special))==0:
        str_final = ''.join(str_list)
        print(str_final)
        n+=1

  

posted @ 2018-05-09 14:13  tengfei520  阅读(1642)  评论(0编辑  收藏  举报