快速生成10w随机邮箱Python代码

需要安装python运行  运行会自动生成一个邮箱2.csv 的文件

嫌麻烦也可以使用在线版的

https://www.tl.beer/randmail.html

# -*- coding: UTF-8 -*-
"""
@author:JCS
@file:多线Mac.py
@time:2022/08/17
"""
import csv
import random
from threading import Thread


class thread_run(Thread):
    def __init__(self):
        Thread.__init__(self)

    def run(self):
        mac()


Maclists = []
a = 0

import random
def RandomEmail( emailType=None, rang=None):
    __emailtype = ["@qq.com", "@163.com", "@126.com", "@189.com"]
    # 如果没有指定邮箱类型,默认在 __emailtype中随机一个
    if emailType == None:
        __randomEmail = random.choice(__emailtype)
    else:
        __randomEmail = emailType
    # 如果没有指定邮箱长度,默认在4-10之间随机
    if rang == None:
        __rang = random.randint(4, 10)
    else:
        __rang = int(rang)
    __Number = "0123456789qbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPWRSTUVWXYZ"
    __randomNumber = "".join(random.choice(__Number) for i in range(__rang))
    _email = __randomNumber + __randomEmail
    return _email

def mac():
    global Maclists
    global a
    while a < b:
        Maclists.append(RandomEmail())   #RandomEmail(emailType='@qq.com',rang=20)如果没有指定邮箱长度,默认在4-10之间随机

        a += 1
        print(f"生成第{a}条")


def writer_mac():
    log_path = '邮箱2.csv'
    file = open(log_path, 'a+', encoding='utf-8', newline='')
    csv_writer = csv.writer(file)
    for i in Maclists:
        csv_writer.writerow([i])
    file.close()


if __name__ == '__main__':
    b = 100000             #数量控制
    for x in range(1000):
        worker = thread_run()
        worker.daemon = True
        worker.start()
    while True:
        if a >=b:
            writer_mac()
            print(f"追加写入{a}条")
            break
        else:
            ...


 

 

1.7/5 - (4 votes)

版权声明: 本站相关资源均存于来自于互联网,和网友投稿发送如果侵权或资源下载地址失效,如遇此情况可于本文留言或tg:@bayuechangan 联系博主,谢谢!!
下载本站软件注意:网站分享的软件资源并非本人原创,使用之前建议虚拟机运行
链接:https://dumuzhou.org/1560.html
文章版权归作者所有

THE END
分享
二维码
< <上一篇
下一篇>>
文章目录
关闭
目 录