python 随机生成用户名、密码、手机号码

时间:2024-07-03 22:36:32
#!C:\Python
#!/usr/bin/env python
#-*- coding:utf-8 -*- import string
import random minlength = 6
maxlength = 16 mobile_begin_seed = ['','','','','','','','','','','','','','','','','','','','','','','','','','','','','','']
mobile_seed = string.digits
username_seed = string.digits+string.ascii_letters
password_seed = string.digits+string.ascii_letters+string.punctuation mobile = random.choice(mobile_begin_seed)+''.join(random.choice(mobile_seed) for m in range(8))
username = ''.join(random.choice(username_seed) for u in range(random.randint(minlength,maxlength)))
password = ''.join(random.choice(password_seed) for p in range(random.randint(minlength,maxlength))) with open("E:\log.log",'a') as log,open ("E:\mobile.txt",'a') as phone:
log.write(username +'\n')
log.write(password +'\n')
phone.write(mobile +'\n') print "The random generation mobile is:",mobile
print "The random generation username is:",username
print "The random generation password is:",password