【Python】密码生成器
import random import string print("欢迎使用密码生成器") def passlength(): print("你想要多长的密码:") global passlen try: input1=input() passlen=int(input1) except: print("请输入一个数字") passlength() if passlen<5: print("太短了😂") passlength() elif passlen>30: print("太长了😂") passlength() else: print("好的😄") passlength() def passwordgen(): chars=string.ascii_letters+string.digits+"@$*!?/" password="" for x in range(passlen): password=password+random.choice(chars) print("你的密码是:"+password) passwordgen()
本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/12120610.html