码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2015-12-02 22:33:23      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

#!C:\Python
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import string
import random

minlength = 6
maxlength = 16

mobile_begin_seed = [‘134‘,‘135‘,‘136‘,‘137‘,‘138‘,‘139‘,‘150‘,‘151‘,‘152‘,‘157‘,‘158‘,‘159‘,‘182‘,‘183‘,‘187‘,‘188‘,‘130‘,‘131‘,‘132‘,‘155‘,‘156‘,‘175‘,‘185‘,‘186‘,‘133‘,‘153‘,‘177‘,‘180‘,‘181‘,‘189‘]
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

 

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

标签:

原文地址:http://www.cnblogs.com/smstars/p/5014265.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!