随机生成用户名和密码
网上注册东西总是提示用户名已被注册过,密码又不提倡简单单词的组合。于是索性写个小程序,自动帮我不停的生成username和password,只到生成的标识看起来满意为止。
import string
import random
firstchar=string.letters+'_'
otherchar=firstchar+string.digits
while True:
username=random.choice(firstchar)
password=random.choice(otherchar)
for x in range(9):
username+=random.choice(otherchar)
password+=random.choice(otherchar)
mycase=raw_input('Show lower of string? Y/N :\t')
if mycase.lower()=='n':
print 'The username is : %s'% username
print 'The password is : %s'% password
elif mycase.lower()=='y':
print 'The username is : %s'% username.lower()
print 'The password is : %s'% password.lower()
else:
print 'Must input Y or N.'
ch=raw_input('Press "C" Show Next Solution.\t')
if ch.lower() !='c':
break