# -*- coding:utf8 -*- import random import string import sys reload(sys) sys.setdefaultencoding("utf8") def random_number(): pwnumber=input("请输入需要密码个数:") pwlength=input("请输入需要密码长度:") if pwlength<=10: for i in range(pwnumber): number=string.join(random.sample(string.digits+string.letters,pwlength)).replace(' ','') print number else : print "目前只支持10位以下密码,请重试!!" random_number() if __name__=="__main__": random_number()