'''你是一個高級測試工程師,現在要做性能測試,需要你寫一個函數,批量生成一些注冊使用的賬號。
1、產生的賬號是以@163.com結尾,長度由用戶輸,產生多少條也由用戶輸入,
2、用戶名不能重復,用戶名必須由大寫字母、小寫字母、數字組成,結果如下圖:
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)