本文实例讲述了python3实现生成随机密码的方法,在python程序设计中有着广泛的实用价值。具体方法如下:
本文实例主要实现创建8位随机密码(大小写字母+数字),采用Python3生成了初级算法的随机密码。
主要功能代码如下:
__author__ = 'Goopand' import string import random def genPassword(length=8,chars=string.digits+string.ascii_letters): return ''.join(random.sample(chars*10,8)) if __name__=="__main__": for i in range(10): print(genPassword(8))
希望本文所述实例对大家Python程序设计有所帮助。
python怎么学习?python怎么入门?python在哪学?python怎么学才快?不用担心,这里为大家提供了python速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号