password_rule.json(password_ rule.json)

def rule():
    import itertools as its
    charsetString = string.digits + string.ascii_letters + string.punctuation
    # 生成密码本的位数,五位数,repeat=5
    dic = {}
    for i in range(1, 5):
        pwd_tuple = its.product(charsetString, repeat=i)
        lis = []
        for pwd in pwd_tuple:
            pwd = ''.join(pwd)
            lis.append(pwd)
        dic.update({str(i): lis})
        print(lis[0])
    with open('password_rule_new.json', 'w', encoding='utf-8') as w:
        w.write(json.dumps(dic))
————————
def rule():
    import itertools as its
    charsetString = string.digits + string.ascii_letters + string.punctuation
    # 生成密码本的位数,五位数,repeat=5
    dic = {}
    for i in range(1, 5):
        pwd_tuple = its.product(charsetString, repeat=i)
        lis = []
        for pwd in pwd_tuple:
            pwd = ''.join(pwd)
            lis.append(pwd)
        dic.update({str(i): lis})
        print(lis[0])
    with open('password_rule_new.json', 'w', encoding='utf-8') as w:
        w.write(json.dumps(dic))