python生成随机密码或随机字符串的方法
更新时间:2015年07月03日 16:01:04 作者:pythoner
这篇文章主要介绍了python生成随机密码或随机字符串的方法,涉及Python字符串及随机数的相关使用技巧,非常简单实用,需要的朋友可以参考下
本文实例讲述了python生成随机密码或随机字符串的方法。分享给大家供大家参考。具体实现方法如下:
import string,random def makePassword(minlength=5,maxlength=25): length=random.randint(minlength,maxlength) letters=string.ascii_letters+string.digits # alphanumeric, upper and lowercase return ''.join([random.choice(letters) for _ in range(length)])
希望本文所述对大家的Python程序设计有所帮助。
相关文章
2020新版本pycharm+anaconda+opencv+pyqt环境配置学习笔记,亲测可用
这篇文章主要介绍了2020新版本pycharm+anaconda+opencv+pyqt环境配置学习笔记,亲测可用,特此分享到脚本之家平台,需要的朋友可以参考下2020-03-03
最新评论