您的位置:首页 > 编程语言 > Python开发

使用random模块,生成动态随机密码 分类: python 小练习 python Module 2013-12-04 17:23 278人阅读 评论(0) 收藏

2013-12-04 17:23 1096 查看
生成动态随机密码:

import random,string

'''
length -- 指定密码的长度
chars  -- 指定密码有字母、数字、下划线及@、#组成
times  -- 指定一次生成的密码个数
'''
chars = string.lowercase+string.uppercase+''.join(map(str,range(10)))+'_@#'

def getpasswd(length = 6,times = 8,chars = chars):
for i in range(times):
print ''.join([random.choice(chars)  for i in range(length)])

getpasswd()
getpasswd(length = 2,times=1)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐