import random passlen = int(input("enter the length of password" )) s=" abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVIXYZ!aN$x*6*( )?" #验证码可以去掉字符和易混淆字母 如L I O 0 p = ".join(random.sample(s,passlen )) print(p)