一个生成随机密码的python脚本,默认生成6个20位的随机字符与数字的组合。可以用来当做服务器的密码,脚本如下:
# cat genpass.py from random import choice import string def GenPasswd(length=20, chars=string.letters+string.digits): return ''.join([choice(chars) for i in range(length)]) for i in range(6): print GenPasswd(20)
运行结果为:
# python genpass.py mv2yMlDEyQFcujkh7ttM 4fNmbh2atrcrsrKm1f3t UKRPsUsdZ951uQBdtPhS bAuHJUbNXBSjB5IVibQO d7Dl0VGAOI0LcGlnJOeR qb2WEHwHTVYK51gZsa2V