import random import pypinyin def gen_mail(word): # 根据姓名生成邮箱号 s = '' for i in pypinyin.pinyin(word, style=pypinyin.NORMAL): s += ''.join(i) r = '' for _ in range(4): r += str(random.randint(1,9)) domain_list = ['163.com', 'qq.com', 'foxmail.com', '139.com', '189.com', 'aliyun.com', 'sina.com', 'mail.sohu.com'] domain = random.choice(domain_list) return f'{s}{r}@{domain}' print(gen_mail('张三')) # [email protected]
标签:domain,random,pypinyin,生成,姓名,mail,邮箱,com From: https://www.cnblogs.com/daizichuan/p/17543080.html