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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM