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

posted @ 2019-12-30 16:58  木子欢儿  阅读(767)  评论(0编辑  收藏  举报