python 生成动态密码

import string
import random
def gen_psd(length=10):
  """length is password length"""
  letters = string.ascii_lowercase + string.digits
  times = length/len(letters)+1
  #print('times: ', times)
  pswd = ''.join([random.choice(letters*int(times)) for _ in range(length)])
  return pswd

if __name__ == '__main__':
  print(gen_psd(57))

posted @ 2017-08-19 18:27  Python_ZEN  阅读(772)  评论(0编辑  收藏  举报