Python 制作邮箱大全文件(含密码)

# 创建的账户并非真实账户,

import random

import os

path = r"D:\Pycharm\shun\wang\day10\n_作业\mail.txt"


def mail():

if os.path.isfile(path):

f = open(path, "w")

num = 0

times = int(input("需要多少个邮箱账户?"))

while num < times:

random_num = random.randint(100000000, 99999999999)

# 1)、随机用户名,格式为"姓名缩写+手机号"
# name_list是包含26个英语字母的列表
name_list = [chr(x) for x in range(ord("a"), ord("z") + 1)]

random.shuffle(name_list)

name = name_list[0] + name_list[1] + name_list[2]

random_num1 = random.randint(100000, 999999)

username = name + str(random_num1)

# 2)、随机邮箱
mail_name_list = [163, "qq", "gmail", 126]

random_num2 = random.randint(0, 3)

mail_name = mail_name_list[random_num2]

# 因为qq邮箱都是qq号码,所以需要判断一下
if mail_name == "qq":

username = random_num

# 3)、随机密码

# 包含小写字母
small_list = [chr(b) for b in range(ord("A"), ord("Z") + 1)]

# 包含数字
num_list = [chr(a) for a in range(ord("0"), ord("9") + 1)]

str1 = "".join(name_list + num_list + small_list)

password = random.sample(str1, 10)

# random中的sample函数会随机拿出10个字符组成列表,因此需要再次用到join函数
passwd = "".join(password)

f.write("%s@%s.com----%s\n" % (username, mail_name, passwd))

num += 1

# 如果没有此文件,就会创建此文件
else:

file1 = open(path, "w")

file1.close()

mail()


mail()
上一篇:循环群阶的关系 ord(a^k)=ord(a)/(ord(a),k)


下一篇:Python3 ord() 函数