📂python
🔖random
2019-07-29 11:47阅读: 1376评论: 0推荐: 0

python3 使用random函数批量产生注册邮箱

'''你是一个高级测试工程师,现在要做性能测试,需要你写一个函数,批量生成一些注册使用的账号。

1、产生的账号是以@163.com结尾,长度由用户输,产生多少条也由用户输入,
2、用户名不能重复,用户名必须由大写字母、小写字母、数字组成,结果如下图:

 

复制代码
 1 import random,string
 2 
 3 def users(count,legth):
 4     with open('users.txt','w') as f:
 5         for i in range(count):
 6             str1 = ''.join(random.sample(string.ascii_letters,legth-1))
 7             str2 = ''.join(random.sample(string.digits,3))
 8             f.write(str1 + str2 + '@163.com' + '\n')
 9 count = int(input('请输入需要产生邮箱的个数:').strip())
10 legth = int(input('请输入邮箱长度:').strip())
11 users(count,legth)
复制代码

 

本文作者:香菜哥哥

本文链接:https://www.cnblogs.com/yizhipanghu/p/11263058.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   香菜哥哥  阅读(1376)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
展开