码迷,mamicode.com
首页 > 编程语言 > 详细

python 生成动态密码

时间:2017-08-19 20:03:01      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:import   let   and   port   for   join   ring   psd   int   

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) for _ in range(length*int(times))])
  return pswd

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

python 生成动态密码

标签:import   let   and   port   for   join   ring   psd   int   

原文地址:http://www.cnblogs.com/python-zen/p/7397513.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!