import random strings=list(‘qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM‘) random.shuffle(strings)#改变strings内容元素的排列次序 print ‘‘.join(random.sample(strings,8))#最前8位
python生成随机密码
原文:http://www.cnblogs.com/JiangLe/p/4950735.html