一個生成隨機密碼的python腳本,默認生成6個20位的隨機字符與數字的組合。能夠用來當作服務器的密碼,腳本以下:python
# 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)
運行結果爲:git
# python genpass.py mv2yMlDEyQFcujkh7ttM 4fNmbh2atrcrsrKm1f3t UKRPsUsdZ951uQBdtPhS bAuHJUbNXBSjB5IVibQO d7Dl0VGAOI0LcGlnJOeR qb2WEHwHTVYK51gZsa2V