Locust学习笔记6——参数化

  引言

  前面一篇文章cust学习笔记5——登录接口参数关联,简单介绍了关联的使用方法,我们不管做接口功能测试还是接口性能测试,都涉及关联、参数化和检查点。那么现在介绍一下参数化。

  背景

  案例场景:所有并发虚拟用户共享同一份测试数据,并且保证虚拟用户使用的数据不重复。

  例如,模拟3用户并发注册账号,总共有9个账号,要求注册账号不重复,注册完毕后结束测试;加载示例如下表所示。

  

  数据准备

  虚拟用户可以在脚本里设置好,而测试数据可以提前写好。

  上面已经讲了背景,这里我要100个用户同时登录来测试系统的性能,相同的用户登录肯定不符合实际要求,此时我们可以考虑用参数化。

  Python的Queue模块中提供了同步的、线程安全的队列类,其中一个队列类就是FIFO(先入先出)队列Queue,用队列将有效用户生成出来put到对列中,在从队列中get出来,传给登录请求。

  法1:

data = {
        "username": "test%04d",
        "password": "pwd%04d",
        "email": "test%[email protected]",
        "phone": "186%08d"
        }
result = [str(data) % (i,i,i,i) for i in range(100)]
print(result)

  结果:

["{'username': 'test0000', 'password': 'pwd0000', 'email': '[email protected]', 'phone': '18600000000'}", "{'username': 'test0001', 'password': 'pwd0001', 'email': '[email protected]', 'phone': '18600000001'}", "{'username': 'test0002', 'password': 'pwd0002', 'email': '[email protected]', 'phone': '18600000002'}", "{'username': 'test0003', 'password': 'pwd0003', 'email': '[email protected]', 'phone': '18600000003'}", "{'username': 'test0004', 'password': 'pwd0004', 'email': '[email protected]', 'phone': '18600000004'}", "{'username': 'test0005', 'password': 'pwd0005', 'email': '[email protected]', 'phone': '18600000005'}", "{'username': 'test0006', 'password': 'pwd0006', 'email': '[email protected]', 'phone': '18600000006'}", "{'username': 'test0007', 'password': 'pwd0007', 'email': '[email protected]', 'phone': '18600000007'}", "{'username': 'test0008', 'password': 'pwd0008', 'email': '[email protected]', 'phone': '18600000008'}", "{'username': 'test0009', 'password': 'pwd0009', 'email': '[email protected]', 'phone': '18600000009'}", "{'username': 'test0010', 'password': 'pwd0010', 'email': '[email protected]', 'phone': '18600000010'}", "{'username': 'test0011', 'password': 'pwd0011', 'email': '[email protected]', 'phone': '18600000011'}", "{'username': 'test0012', 'password': 'pwd0012', 'email': '[email protected]', 'phone': '18600000012'}", "{'username': 'test0013', 'password': 'pwd0013', 'email': '[email protected]', 'phone': '18600000013'}", "{'username': 'test0014', 'password': 'pwd0014', 'email': '[email protected]', 'phone': '18600000014'}", "{'username': 'test0015', 'password': 'pwd0015', 'email': '[email protected]', 'phone': '18600000015'}", "{'username': 'test0016', 'password': 'pwd0016', 'email': '[email protected]', 'phone': '18600000016'}", "{'username': 'test0017', 'password': 'pwd0017', 'email': '[email protected]', 'phone': '18600000017'}", "{'username': 'test0018', 'password': 'pwd0018', 'email': '[email protected]', 'phone': '18600000018'}", "{'username': 'test0019', 'password': 'pwd0019', 'email': '[email protected]', 'phone': '18600000019'}", "{'username': 'test0020', 'password': 'pwd0020', 'email': '[email protected]', 'phone': '18600000020'}", "{'username': 'test0021', 'password': 'pwd0021', 'email': '[email protected]', 'phone': '18600000021'}", "{'username': 'test0022', 'password': 'pwd0022', 'email': '[email protected]', 'phone': '18600000022'}", "{'username': 'test0023', 'password': 'pwd0023', 'email': '[email protected]', 'phone': '18600000023'}", "{'username': 'test0024', 'password': 'pwd0024', 'email': '[email protected]', 'phone': '18600000024'}", "{'username': 'test0025', 'password': 'pwd0025', 'email': '[email protected]', 'phone': '18600000025'}", "{'username': 'test0026', 'password': 'pwd0026', 'email': '[email protected]', 'phone': '18600000026'}", "{'username': 'test0027', 'password': 'pwd0027', 'email': '[email protected]', 'phone': '18600000027'}", "{'username': 'test0028', 'password': 'pwd0028', 'email': '[email protected]', 'phone': '18600000028'}", "{'username': 'test0029', 'password': 'pwd0029', 'email': '[email protected]', 'phone': '18600000029'}", "{'username': 'test0030', 'password': 'pwd0030', 'email': '[email protected]', 'phone': '18600000030'}", "{'username': 'test0031', 'password': 'pwd0031', 'email': '[email protected]', 'phone': '18600000031'}", "{'username': 'test0032', 'password': 'pwd0032', 'email': '[email protected]', 'phone': '18600000032'}", "{'username': 'test0033', 'password': 'pwd0033', 'email': '[email protected]', 'phone': '18600000033'}", "{'username': 'test0034', 'password': 'pwd0034', 'email': '[email protected]', 'phone': '18600000034'}", "{'username': 'test0035', 'password': 'pwd0035', 'email': '[email protected]', 'phone': '18600000035'}", "{'username': 'test0036', 'password': 'pwd0036', 'email': '[email protected]', 'phone': '18600000036'}", "{'username': 'test0037', 'password': 'pwd0037', 'email': '[email protected]', 'phone': '18600000037'}", "{'username': 'test0038', 'password': 'pwd0038', 'email': '[email protected]', 'phone': '18600000038'}", "{'username': 'test0039', 'password': 'pwd0039', 'email': '[email protected]', 'phone': '18600000039'}", "{'username': 'test0040', 'password': 'pwd0040', 'email': '[email protected]', 'phone': '18600000040'}", "{'username': 'test0041', 'password': 'pwd0041', 'email': '[email protected]', 'phone': '18600000041'}", "{'username': 'test0042', 'password': 'pwd0042', 'email': '[email protected]', 'phone': '18600000042'}", "{'username': 'test0043', 'password': 'pwd0043', 'email': '[email protected]', 'phone': '18600000043'}", "{'username': 'test0044', 'password': 'pwd0044', 'email': '[email protected]', 'phone': '18600000044'}", "{'username': 'test0045', 'password': 'pwd0045', 'email': '[email protected]', 'phone': '18600000045'}", "{'username': 'test0046', 'password': 'pwd0046', 'email': '[email protected]', 'phone': '18600000046'}", "{'username': 'test0047', 'password': 'pwd0047', 'email': '[email protected]', 'phone': '18600000047'}", "{'username': 'test0048', 'password': 'pwd0048', 'email': '[email protected]', 'phone': '18600000048'}", "{'username': 'test0049', 'password': 'pwd0049', 'email': '[email protected]', 'phone': '18600000049'}", "{'username': 'test0050', 'password': 'pwd0050', 'email': '[email protected]', 'phone': '18600000050'}", "{'username': 'test0051', 'password': 'pwd0051', 'email': '[email protected]', 'phone': '18600000051'}", "{'username': 'test0052', 'password': 'pwd0052', 'email': '[email protected]', 'phone': '18600000052'}", "{'username': 'test0053', 'password': 'pwd0053', 'email': '[email protected]', 'phone': '18600000053'}", "{'username': 'test0054', 'password': 'pwd0054', 'email': '[email protected]', 'phone': '18600000054'}", "{'username': 'test0055', 'password': 'pwd0055', 'email': '[email protected]', 'phone': '18600000055'}", "{'username': 'test0056', 'password': 'pwd0056', 'email': '[email protected]', 'phone': '18600000056'}", "{'username': 'test0057', 'password': 'pwd0057', 'email': '[email protected]', 'phone': '18600000057'}", "{'username': 'test0058', 'password': 'pwd0058', 'email': '[email protected]', 'phone': '18600000058'}", "{'username': 'test0059', 'password': 'pwd0059', 'email': '[email protected]', 'phone': '18600000059'}", "{'username': 'test0060', 'password': 'pwd0060', 'email': '[email protected]', 'phone': '18600000060'}", "{'username': 'test0061', 'password': 'pwd0061', 'email': '[email protected]', 'phone': '18600000061'}", "{'username': 'test0062', 'password': 'pwd0062', 'email': '[email protected]', 'phone': '18600000062'}", "{'username': 'test0063', 'password': 'pwd0063', 'email': '[email protected]', 'phone': '18600000063'}", "{'username': 'test0064', 'password': 'pwd0064', 'email': '[email protected]', 'phone': '18600000064'}", "{'username': 'test0065', 'password': 'pwd0065', 'email': '[email protected]', 'phone': '18600000065'}", "{'username': 'test0066', 'password': 'pwd0066', 'email': '[email protected]', 'phone': '18600000066'}", "{'username': 'test0067', 'password': 'pwd0067', 'email': '[email protected]', 'phone': '18600000067'}", "{'username': 'test0068', 'password': 'pwd0068', 'email': '[email protected]', 'phone': '18600000068'}", "{'username': 'test0069', 'password': 'pwd0069', 'email': '[email protected]', 'phone': '18600000069'}", "{'username': 'test0070', 'password': 'pwd0070', 'email': '[email protected]', 'phone': '18600000070'}", "{'username': 'test0071', 'password': 'pwd0071', 'email': '[email protected]', 'phone': '18600000071'}", "{'username': 'test0072', 'password': 'pwd0072', 'email': '[email protected]', 'phone': '18600000072'}", "{'username': 'test0073', 'password': 'pwd0073', 'email': '[email protected]', 'phone': '18600000073'}", "{'username': 'test0074', 'password': 'pwd0074', 'email': '[email protected]', 'phone': '18600000074'}", "{'username': 'test0075', 'password': 'pwd0075', 'email': '[email protected]', 'phone': '18600000075'}", "{'username': 'test0076', 'password': 'pwd0076', 'email': '[email protected]', 'phone': '18600000076'}", "{'username': 'test0077', 'password': 'pwd0077', 'email': '[email protected]', 'phone': '18600000077'}", "{'username': 'test0078', 'password': 'pwd0078', 'email': '[email protected]', 'phone': '18600000078'}", "{'username': 'test0079', 'password': 'pwd0079', 'email': '[email protected]', 'phone': '18600000079'}", "{'username': 'test0080', 'password': 'pwd0080', 'email': '[email protected]', 'phone': '18600000080'}", "{'username': 'test0081', 'password': 'pwd0081', 'email': '[email protected]', 'phone': '18600000081'}", "{'username': 'test0082', 'password': 'pwd0082', 'email': '[email protected]', 'phone': '18600000082'}", "{'username': 'test0083', 'password': 'pwd0083', 'email': '[email protected]', 'phone': '18600000083'}", "{'username': 'test0084', 'password': 'pwd0084', 'email': '[email protected]', 'phone': '18600000084'}", "{'username': 'test0085', 'password': 'pwd0085', 'email': '[email protected]', 'phone': '18600000085'}", "{'username': 'test0086', 'password': 'pwd0086', 'email': '[email protected]', 'phone': '18600000086'}", "{'username': 'test0087', 'password': 'pwd0087', 'email': '[email protected]', 'phone': '18600000087'}", "{'username': 'test0088', 'password': 'pwd0088', 'email': '[email protected]', 'phone': '18600000088'}", "{'username': 'test0089', 'password': 'pwd0089', 'email': '[email protected]', 'phone': '18600000089'}", "{'username': 'test0090', 'password': 'pwd0090', 'email': '[email protected]', 'phone': '18600000090'}", "{'username': 'test0091', 'password': 'pwd0091', 'email': '[email protected]', 'phone': '18600000091'}", "{'username': 'test0092', 'password': 'pwd0092', 'email': '[email protected]', 'phone': '18600000092'}", "{'username': 'test0093', 'password': 'pwd0093', 'email': '[email protected]', 'phone': '18600000093'}", "{'username': 'test0094', 'password': 'pwd0094', 'email': '[email protected]', 'phone': '18600000094'}", "{'username': 'test0095', 'password': 'pwd0095', 'email': '[email protected]', 'phone': '18600000095'}", "{'username': 'test0096', 'password': 'pwd0096', 'email': '[email protected]', 'phone': '18600000096'}", "{'username': 'test0097', 'password': 'pwd0097', 'email': '[email protected]', 'phone': '18600000097'}", "{'username': 'test0098', 'password': 'pwd0098', 'email': '[email protected]', 'phone': '18600000098'}", "{'username': 'test0099', 'password': 'pwd0099', 'email': '[email protected]', 'phone': '18600000099'}"]

Process finished with exit code 0

  法2:

result_list = []
for index in range(100):
    data = '''{
    "username": "test%04d",
    "password": "pwd%04d",
    "email": "test%[email protected]",
    "phone": "186%08d",
    }'''%(index,index,index,index)
    result_list.append(data.replace(' ',''))
print(result_list)
clear_space =  [x.replace('\n','') for x in result_list]
print(clear_space)

  结果:

['{\n"username":"test0000",\n"password":"pwd0000",\n"email":"[email protected]",\n"phone":"18600000000",\n}', '{\n"username":"test0001",\n"password":"pwd0001",\n"email":"[email protected]",\n"phone":"18600000001",\n}', '{\n"username":"test0002",\n"password":"pwd0002",\n"email":"[email protected]",\n"phone":"18600000002",\n}', '{\n"username":"test0003",\n"password":"pwd0003",\n"email":"[email protected]",\n"phone":"18600000003",\n}', '{\n"username":"test0004",\n"password":"pwd0004",\n"email":"[email protected]",\n"phone":"18600000004",\n}', '{\n"username":"test0005",\n"password":"pwd0005",\n"email":"[email protected]",\n"phone":"18600000005",\n}', '{\n"username":"test0006",\n"password":"pwd0006",\n"email":"[email protected]",\n"phone":"18600000006",\n}', '{\n"username":"test0007",\n"password":"pwd0007",\n"email":"[email protected]",\n"phone":"18600000007",\n}', '{\n"username":"test0008",\n"password":"pwd0008",\n"email":"[email protected]",\n"phone":"18600000008",\n}', '{\n"username":"test0009",\n"password":"pwd0009",\n"email":"[email protected]",\n"phone":"18600000009",\n}', '{\n"username":"test0010",\n"password":"pwd0010",\n"email":"[email protected]",\n"phone":"18600000010",\n}', '{\n"username":"test0011",\n"password":"pwd0011",\n"email":"[email protected]",\n"phone":"18600000011",\n}', '{\n"username":"test0012",\n"password":"pwd0012",\n"email":"[email protected]",\n"phone":"18600000012",\n}', '{\n"username":"test0013",\n"password":"pwd0013",\n"email":"[email protected]",\n"phone":"18600000013",\n}', '{\n"username":"test0014",\n"password":"pwd0014",\n"email":"[email protected]",\n"phone":"18600000014",\n}', '{\n"username":"test0015",\n"password":"pwd0015",\n"email":"[email protected]",\n"phone":"18600000015",\n}', '{\n"username":"test0016",\n"password":"pwd0016",\n"email":"[email protected]",\n"phone":"18600000016",\n}', '{\n"username":"test0017",\n"password":"pwd0017",\n"email":"[email protected]",\n"phone":"18600000017",\n}', '{\n"username":"test0018",\n"password":"pwd0018",\n"email":"[email protected]",\n"phone":"18600000018",\n}', '{\n"username":"test0019",\n"password":"pwd0019",\n"email":"[email protected]",\n"phone":"18600000019",\n}', '{\n"username":"test0020",\n"password":"pwd0020",\n"email":"[email protected]",\n"phone":"18600000020",\n}', '{\n"username":"test0021",\n"password":"pwd0021",\n"email":"[email protected]",\n"phone":"18600000021",\n}', '{\n"username":"test0022",\n"password":"pwd0022",\n"email":"[email protected]",\n"phone":"18600000022",\n}', '{\n"username":"test0023",\n"password":"pwd0023",\n"email":"[email protected]",\n"phone":"18600000023",\n}', '{\n"username":"test0024",\n"password":"pwd0024",\n"email":"[email protected]",\n"phone":"18600000024",\n}', '{\n"username":"test0025",\n"password":"pwd0025",\n"email":"[email protected]",\n"phone":"18600000025",\n}', '{\n"username":"test0026",\n"password":"pwd0026",\n"email":"[email protected]",\n"phone":"18600000026",\n}', '{\n"username":"test0027",\n"password":"pwd0027",\n"email":"[email protected]",\n"phone":"18600000027",\n}', '{\n"username":"test0028",\n"password":"pwd0028",\n"email":"[email protected]",\n"phone":"18600000028",\n}', '{\n"username":"test0029",\n"password":"pwd0029",\n"email":"[email protected]",\n"phone":"18600000029",\n}', '{\n"username":"test0030",\n"password":"pwd0030",\n"email":"[email protected]",\n"phone":"18600000030",\n}', '{\n"username":"test0031",\n"password":"pwd0031",\n"email":"[email protected]",\n"phone":"18600000031",\n}', '{\n"username":"test0032",\n"password":"pwd0032",\n"email":"[email protected]",\n"phone":"18600000032",\n}', '{\n"username":"test0033",\n"password":"pwd0033",\n"email":"[email protected]",\n"phone":"18600000033",\n}', '{\n"username":"test0034",\n"password":"pwd0034",\n"email":"[email protected]",\n"phone":"18600000034",\n}', '{\n"username":"test0035",\n"password":"pwd0035",\n"email":"[email protected]",\n"phone":"18600000035",\n}', '{\n"username":"test0036",\n"password":"pwd0036",\n"email":"[email protected]",\n"phone":"18600000036",\n}', '{\n"username":"test0037",\n"password":"pwd0037",\n"email":"[email protected]",\n"phone":"18600000037",\n}', '{\n"username":"test0038",\n"password":"pwd0038",\n"email":"[email protected]",\n"phone":"18600000038",\n}', '{\n"username":"test0039",\n"password":"pwd0039",\n"email":"[email protected]",\n"phone":"18600000039",\n}', '{\n"username":"test0040",\n"password":"pwd0040",\n"email":"[email protected]",\n"phone":"18600000040",\n}', '{\n"username":"test0041",\n"password":"pwd0041",\n"email":"[email protected]",\n"phone":"18600000041",\n}', '{\n"username":"test0042",\n"password":"pwd0042",\n"email":"[email protected]",\n"phone":"18600000042",\n}', '{\n"username":"test0043",\n"password":"pwd0043",\n"email":"[email protected]",\n"phone":"18600000043",\n}', '{\n"username":"test0044",\n"password":"pwd0044",\n"email":"[email protected]",\n"phone":"18600000044",\n}', '{\n"username":"test0045",\n"password":"pwd0045",\n"email":"[email protected]",\n"phone":"18600000045",\n}', '{\n"username":"test0046",\n"password":"pwd0046",\n"email":"[email protected]",\n"phone":"18600000046",\n}', '{\n"username":"test0047",\n"password":"pwd0047",\n"email":"[email protected]",\n"phone":"18600000047",\n}', '{\n"username":"test0048",\n"password":"pwd0048",\n"email":"[email protected]",\n"phone":"18600000048",\n}', '{\n"username":"test0049",\n"password":"pwd0049",\n"email":"[email protected]",\n"phone":"18600000049",\n}', '{\n"username":"test0050",\n"password":"pwd0050",\n"email":"[email protected]",\n"phone":"18600000050",\n}', '{\n"username":"test0051",\n"password":"pwd0051",\n"email":"[email protected]",\n"phone":"18600000051",\n}', '{\n"username":"test0052",\n"password":"pwd0052",\n"email":"[email protected]",\n"phone":"18600000052",\n}', '{\n"username":"test0053",\n"password":"pwd0053",\n"email":"[email protected]",\n"phone":"18600000053",\n}', '{\n"username":"test0054",\n"password":"pwd0054",\n"email":"[email protected]",\n"phone":"18600000054",\n}', '{\n"username":"test0055",\n"password":"pwd0055",\n"email":"[email protected]",\n"phone":"18600000055",\n}', '{\n"username":"test0056",\n"password":"pwd0056",\n"email":"[email protected]",\n"phone":"18600000056",\n}', '{\n"username":"test0057",\n"password":"pwd0057",\n"email":"[email protected]",\n"phone":"18600000057",\n}', '{\n"username":"test0058",\n"password":"pwd0058",\n"email":"[email protected]",\n"phone":"18600000058",\n}', '{\n"username":"test0059",\n"password":"pwd0059",\n"email":"[email protected]",\n"phone":"18600000059",\n}', '{\n"username":"test0060",\n"password":"pwd0060",\n"email":"[email protected]",\n"phone":"18600000060",\n}', '{\n"username":"test0061",\n"password":"pwd0061",\n"email":"[email protected]",\n"phone":"18600000061",\n}', '{\n"username":"test0062",\n"password":"pwd0062",\n"email":"[email protected]",\n"phone":"18600000062",\n}', '{\n"username":"test0063",\n"password":"pwd0063",\n"email":"[email protected]",\n"phone":"18600000063",\n}', '{\n"username":"test0064",\n"password":"pwd0064",\n"email":"[email protected]",\n"phone":"18600000064",\n}', '{\n"username":"test0065",\n"password":"pwd0065",\n"email":"[email protected]",\n"phone":"18600000065",\n}', '{\n"username":"test0066",\n"password":"pwd0066",\n"email":"[email protected]",\n"phone":"18600000066",\n}', '{\n"username":"test0067",\n"password":"pwd0067",\n"email":"[email protected]",\n"phone":"18600000067",\n}', '{\n"username":"test0068",\n"password":"pwd0068",\n"email":"[email protected]",\n"phone":"18600000068",\n}', '{\n"username":"test0069",\n"password":"pwd0069",\n"email":"[email protected]",\n"phone":"18600000069",\n}', '{\n"username":"test0070",\n"password":"pwd0070",\n"email":"[email protected]",\n"phone":"18600000070",\n}', '{\n"username":"test0071",\n"password":"pwd0071",\n"email":"[email protected]",\n"phone":"18600000071",\n}', '{\n"username":"test0072",\n"password":"pwd0072",\n"email":"[email protected]",\n"phone":"18600000072",\n}', '{\n"username":"test0073",\n"password":"pwd0073",\n"email":"[email protected]",\n"phone":"18600000073",\n}', '{\n"username":"test0074",\n"password":"pwd0074",\n"email":"[email protected]",\n"phone":"18600000074",\n}', '{\n"username":"test0075",\n"password":"pwd0075",\n"email":"[email protected]",\n"phone":"18600000075",\n}', '{\n"username":"test0076",\n"password":"pwd0076",\n"email":"[email protected]",\n"phone":"18600000076",\n}', '{\n"username":"test0077",\n"password":"pwd0077",\n"email":"[email protected]",\n"phone":"18600000077",\n}', '{\n"username":"test0078",\n"password":"pwd0078",\n"email":"[email protected]",\n"phone":"18600000078",\n}', '{\n"username":"test0079",\n"password":"pwd0079",\n"email":"[email protected]",\n"phone":"18600000079",\n}', '{\n"username":"test0080",\n"password":"pwd0080",\n"email":"[email protected]",\n"phone":"18600000080",\n}', '{\n"username":"test0081",\n"password":"pwd0081",\n"email":"[email protected]",\n"phone":"18600000081",\n}', '{\n"username":"test0082",\n"password":"pwd0082",\n"email":"[email protected]",\n"phone":"18600000082",\n}', '{\n"username":"test0083",\n"password":"pwd0083",\n"email":"[email protected]",\n"phone":"18600000083",\n}', '{\n"username":"test0084",\n"password":"pwd0084",\n"email":"[email protected]",\n"phone":"18600000084",\n}', '{\n"username":"test0085",\n"password":"pwd0085",\n"email":"[email protected]",\n"phone":"18600000085",\n}', '{\n"username":"test0086",\n"password":"pwd0086",\n"email":"[email protected]",\n"phone":"18600000086",\n}', '{\n"username":"test0087",\n"password":"pwd0087",\n"email":"[email protected]",\n"phone":"18600000087",\n}', '{\n"username":"test0088",\n"password":"pwd0088",\n"email":"[email protected]",\n"phone":"18600000088",\n}', '{\n"username":"test0089",\n"password":"pwd0089",\n"email":"[email protected]",\n"phone":"18600000089",\n}', '{\n"username":"test0090",\n"password":"pwd0090",\n"email":"[email protected]",\n"phone":"18600000090",\n}', '{\n"username":"test0091",\n"password":"pwd0091",\n"email":"[email protected]",\n"phone":"18600000091",\n}', '{\n"username":"test0092",\n"password":"pwd0092",\n"email":"[email protected]",\n"phone":"18600000092",\n}', '{\n"username":"test0093",\n"password":"pwd0093",\n"email":"[email protected]",\n"phone":"18600000093",\n}', '{\n"username":"test0094",\n"password":"pwd0094",\n"email":"[email protected]",\n"phone":"18600000094",\n}', '{\n"username":"test0095",\n"password":"pwd0095",\n"email":"[email protected]",\n"phone":"18600000095",\n}', '{\n"username":"test0096",\n"password":"pwd0096",\n"email":"[email protected]",\n"phone":"18600000096",\n}', '{\n"username":"test0097",\n"password":"pwd0097",\n"email":"[email protected]",\n"phone":"18600000097",\n}', '{\n"username":"test0098",\n"password":"pwd0098",\n"email":"[email protected]",\n"phone":"18600000098",\n}', '{\n"username":"test0099",\n"password":"pwd0099",\n"email":"[email protected]",\n"phone":"18600000099",\n}']
['{"username":"test0000","password":"pwd0000","email":"[email protected]","phone":"18600000000",}', '{"username":"test0001","password":"pwd0001","email":"[email protected]","phone":"18600000001",}', '{"username":"test0002","password":"pwd0002","email":"[email protected]","phone":"18600000002",}', '{"username":"test0003","password":"pwd0003","email":"[email protected]","phone":"18600000003",}', '{"username":"test0004","password":"pwd0004","email":"[email protected]","phone":"18600000004",}', '{"username":"test0005","password":"pwd0005","email":"[email protected]","phone":"18600000005",}', '{"username":"test0006","password":"pwd0006","email":"[email protected]","phone":"18600000006",}', '{"username":"test0007","password":"pwd0007","email":"[email protected]","phone":"18600000007",}', '{"username":"test0008","password":"pwd0008","email":"[email protected]","phone":"18600000008",}', '{"username":"test0009","password":"pwd0009","email":"[email protected]","phone":"18600000009",}', '{"username":"test0010","password":"pwd0010","email":"[email protected]","phone":"18600000010",}', '{"username":"test0011","password":"pwd0011","email":"[email protected]","phone":"18600000011",}', '{"username":"test0012","password":"pwd0012","email":"[email protected]","phone":"18600000012",}', '{"username":"test0013","password":"pwd0013","email":"[email protected]","phone":"18600000013",}', '{"username":"test0014","password":"pwd0014","email":"[email protected]","phone":"18600000014",}', '{"username":"test0015","password":"pwd0015","email":"[email protected]","phone":"18600000015",}', '{"username":"test0016","password":"pwd0016","email":"[email protected]","phone":"18600000016",}', '{"username":"test0017","password":"pwd0017","email":"[email protected]","phone":"18600000017",}', '{"username":"test0018","password":"pwd0018","email":"[email protected]","phone":"18600000018",}', '{"username":"test0019","password":"pwd0019","email":"[email protected]","phone":"18600000019",}', '{"username":"test0020","password":"pwd0020","email":"[email protected]","phone":"18600000020",}', '{"username":"test0021","password":"pwd0021","email":"[email protected]","phone":"18600000021",}', '{"username":"test0022","password":"pwd0022","email":"[email protected]","phone":"18600000022",}', '{"username":"test0023","password":"pwd0023","email":"[email protected]","phone":"18600000023",}', '{"username":"test0024","password":"pwd0024","email":"[email protected]","phone":"18600000024",}', '{"username":"test0025","password":"pwd0025","email":"[email protected]","phone":"18600000025",}', '{"username":"test0026","password":"pwd0026","email":"[email protected]","phone":"18600000026",}', '{"username":"test0027","password":"pwd0027","email":"[email protected]","phone":"18600000027",}', '{"username":"test0028","password":"pwd0028","email":"[email protected]","phone":"18600000028",}', '{"username":"test0029","password":"pwd0029","email":"[email protected]","phone":"18600000029",}', '{"username":"test0030","password":"pwd0030","email":"[email protected]","phone":"18600000030",}', '{"username":"test0031","password":"pwd0031","email":"[email protected]","phone":"18600000031",}', '{"username":"test0032","password":"pwd0032","email":"[email protected]","phone":"18600000032",}', '{"username":"test0033","password":"pwd0033","email":"[email protected]","phone":"18600000033",}', '{"username":"test0034","password":"pwd0034","email":"[email protected]","phone":"18600000034",}', '{"username":"test0035","password":"pwd0035","email":"[email protected]","phone":"18600000035",}', '{"username":"test0036","password":"pwd0036","email":"[email protected]","phone":"18600000036",}', '{"username":"test0037","password":"pwd0037","email":"[email protected]","phone":"18600000037",}', '{"username":"test0038","password":"pwd0038","email":"[email protected]","phone":"18600000038",}', '{"username":"test0039","password":"pwd0039","email":"[email protected]","phone":"18600000039",}', '{"username":"test0040","password":"pwd0040","email":"[email protected]","phone":"18600000040",}', '{"username":"test0041","password":"pwd0041","email":"[email protected]","phone":"18600000041",}', '{"username":"test0042","password":"pwd0042","email":"[email protected]","phone":"18600000042",}', '{"username":"test0043","password":"pwd0043","email":"[email protected]","phone":"18600000043",}', '{"username":"test0044","password":"pwd0044","email":"[email protected]","phone":"18600000044",}', '{"username":"test0045","password":"pwd0045","email":"[email protected]","phone":"18600000045",}', '{"username":"test0046","password":"pwd0046","email":"[email protected]","phone":"18600000046",}', '{"username":"test0047","password":"pwd0047","email":"[email protected]","phone":"18600000047",}', '{"username":"test0048","password":"pwd0048","email":"[email protected]","phone":"18600000048",}', '{"username":"test0049","password":"pwd0049","email":"[email protected]","phone":"18600000049",}', '{"username":"test0050","password":"pwd0050","email":"[email protected]","phone":"18600000050",}', '{"username":"test0051","password":"pwd0051","email":"[email protected]","phone":"18600000051",}', '{"username":"test0052","password":"pwd0052","email":"[email protected]","phone":"18600000052",}', '{"username":"test0053","password":"pwd0053","email":"[email protected]","phone":"18600000053",}', '{"username":"test0054","password":"pwd0054","email":"[email protected]","phone":"18600000054",}', '{"username":"test0055","password":"pwd0055","email":"[email protected]","phone":"18600000055",}', '{"username":"test0056","password":"pwd0056","email":"[email protected]","phone":"18600000056",}', '{"username":"test0057","password":"pwd0057","email":"[email protected]","phone":"18600000057",}', '{"username":"test0058","password":"pwd0058","email":"[email protected]","phone":"18600000058",}', '{"username":"test0059","password":"pwd0059","email":"[email protected]","phone":"18600000059",}', '{"username":"test0060","password":"pwd0060","email":"[email protected]","phone":"18600000060",}', '{"username":"test0061","password":"pwd0061","email":"[email protected]","phone":"18600000061",}', '{"username":"test0062","password":"pwd0062","email":"[email protected]","phone":"18600000062",}', '{"username":"test0063","password":"pwd0063","email":"[email protected]","phone":"18600000063",}', '{"username":"test0064","password":"pwd0064","email":"[email protected]","phone":"18600000064",}', '{"username":"test0065","password":"pwd0065","email":"[email protected]","phone":"18600000065",}', '{"username":"test0066","password":"pwd0066","email":"[email protected]","phone":"18600000066",}', '{"username":"test0067","password":"pwd0067","email":"[email protected]","phone":"18600000067",}', '{"username":"test0068","password":"pwd0068","email":"[email protected]","phone":"18600000068",}', '{"username":"test0069","password":"pwd0069","email":"[email protected]","phone":"18600000069",}', '{"username":"test0070","password":"pwd0070","email":"[email protected]","phone":"18600000070",}', '{"username":"test0071","password":"pwd0071","email":"[email protected]","phone":"18600000071",}', '{"username":"test0072","password":"pwd0072","email":"[email protected]","phone":"18600000072",}', '{"username":"test0073","password":"pwd0073","email":"[email protected]","phone":"18600000073",}', '{"username":"test0074","password":"pwd0074","email":"[email protected]","phone":"18600000074",}', '{"username":"test0075","password":"pwd0075","email":"[email protected]","phone":"18600000075",}', '{"username":"test0076","password":"pwd0076","email":"[email protected]","phone":"18600000076",}', '{"username":"test0077","password":"pwd0077","email":"[email protected]","phone":"18600000077",}', '{"username":"test0078","password":"pwd0078","email":"[email protected]","phone":"18600000078",}', '{"username":"test0079","password":"pwd0079","email":"[email protected]","phone":"18600000079",}', '{"username":"test0080","password":"pwd0080","email":"[email protected]","phone":"18600000080",}', '{"username":"test0081","password":"pwd0081","email":"[email protected]","phone":"18600000081",}', '{"username":"test0082","password":"pwd0082","email":"[email protected]","phone":"18600000082",}', '{"username":"test0083","password":"pwd0083","email":"[email protected]","phone":"18600000083",}', '{"username":"test0084","password":"pwd0084","email":"[email protected]","phone":"18600000084",}', '{"username":"test0085","password":"pwd0085","email":"[email protected]","phone":"18600000085",}', '{"username":"test0086","password":"pwd0086","email":"[email protected]","phone":"18600000086",}', '{"username":"test0087","password":"pwd0087","email":"[email protected]","phone":"18600000087",}', '{"username":"test0088","password":"pwd0088","email":"[email protected]","phone":"18600000088",}', '{"username":"test0089","password":"pwd0089","email":"[email protected]","phone":"18600000089",}', '{"username":"test0090","password":"pwd0090","email":"[email protected]","phone":"18600000090",}', '{"username":"test0091","password":"pwd0091","email":"[email protected]","phone":"18600000091",}', '{"username":"test0092","password":"pwd0092","email":"[email protected]","phone":"18600000092",}', '{"username":"test0093","password":"pwd0093","email":"[email protected]","phone":"18600000093",}', '{"username":"test0094","password":"pwd0094","email":"[email protected]","phone":"18600000094",}', '{"username":"test0095","password":"pwd0095","email":"[email protected]","phone":"18600000095",}', '{"username":"test0096","password":"pwd0096","email":"[email protected]","phone":"18600000096",}', '{"username":"test0097","password":"pwd0097","email":"[email protected]","phone":"18600000097",}', '{"username":"test0098","password":"pwd0098","email":"[email protected]","phone":"18600000098",}', '{"username":"test0099","password":"pwd0099","email":"[email protected]","phone":"18600000099",}']

Process finished with exit code 0

  法3:

result_list = []
for index in range(100):
    data = {
            "username": "test%04d" % index,
            "password": "pwd%04d" % index,
            "email": "test%[email protected]" % index,
            "phone": "186%08d" % index,
        }
    result_list.append(data)
print(result_list)

  结果:

[{'username': 'test0000', 'password': 'pwd0000', 'email': '[email protected]', 'phone': '18600000000'}, {'username': 'test0001', 'password': 'pwd0001', 'email': '[email protected]', 'phone': '18600000001'}, {'username': 'test0002', 'password': 'pwd0002', 'email': '[email protected]', 'phone': '18600000002'}, {'username': 'test0003', 'password': 'pwd0003', 'email': '[email protected]', 'phone': '18600000003'}, {'username': 'test0004', 'password': 'pwd0004', 'email': '[email protected]', 'phone': '18600000004'}, {'username': 'test0005', 'password': 'pwd0005', 'email': '[email protected]', 'phone': '18600000005'}, {'username': 'test0006', 'password': 'pwd0006', 'email': '[email protected]', 'phone': '18600000006'}, {'username': 'test0007', 'password': 'pwd0007', 'email': '[email protected]', 'phone': '18600000007'}, {'username': 'test0008', 'password': 'pwd0008', 'email': '[email protected]', 'phone': '18600000008'}, {'username': 'test0009', 'password': 'pwd0009', 'email': '[email protected]', 'phone': '18600000009'}, {'username': 'test0010', 'password': 'pwd0010', 'email': '[email protected]', 'phone': '18600000010'}, {'username': 'test0011', 'password': 'pwd0011', 'email': '[email protected]', 'phone': '18600000011'}, {'username': 'test0012', 'password': 'pwd0012', 'email': '[email protected]', 'phone': '18600000012'}, {'username': 'test0013', 'password': 'pwd0013', 'email': '[email protected]', 'phone': '18600000013'}, {'username': 'test0014', 'password': 'pwd0014', 'email': '[email protected]', 'phone': '18600000014'}, {'username': 'test0015', 'password': 'pwd0015', 'email': '[email protected]', 'phone': '18600000015'}, {'username': 'test0016', 'password': 'pwd0016', 'email': '[email protected]', 'phone': '18600000016'}, {'username': 'test0017', 'password': 'pwd0017', 'email': '[email protected]', 'phone': '18600000017'}, {'username': 'test0018', 'password': 'pwd0018', 'email': '[email protected]', 'phone': '18600000018'}, {'username': 'test0019', 'password': 'pwd0019', 'email': '[email protected]', 'phone': '18600000019'}, {'username': 'test0020', 'password': 'pwd0020', 'email': '[email protected]', 'phone': '18600000020'}, {'username': 'test0021', 'password': 'pwd0021', 'email': '[email protected]', 'phone': '18600000021'}, {'username': 'test0022', 'password': 'pwd0022', 'email': '[email protected]', 'phone': '18600000022'}, {'username': 'test0023', 'password': 'pwd0023', 'email': '[email protected]', 'phone': '18600000023'}, {'username': 'test0024', 'password': 'pwd0024', 'email': '[email protected]', 'phone': '18600000024'}, {'username': 'test0025', 'password': 'pwd0025', 'email': '[email protected]', 'phone': '18600000025'}, {'username': 'test0026', 'password': 'pwd0026', 'email': '[email protected]', 'phone': '18600000026'}, {'username': 'test0027', 'password': 'pwd0027', 'email': '[email protected]', 'phone': '18600000027'}, {'username': 'test0028', 'password': 'pwd0028', 'email': '[email protected]', 'phone': '18600000028'}, {'username': 'test0029', 'password': 'pwd0029', 'email': '[email protected]', 'phone': '18600000029'}, {'username': 'test0030', 'password': 'pwd0030', 'email': '[email protected]', 'phone': '18600000030'}, {'username': 'test0031', 'password': 'pwd0031', 'email': '[email protected]', 'phone': '18600000031'}, {'username': 'test0032', 'password': 'pwd0032', 'email': '[email protected]', 'phone': '18600000032'}, {'username': 'test0033', 'password': 'pwd0033', 'email': '[email protected]', 'phone': '18600000033'}, {'username': 'test0034', 'password': 'pwd0034', 'email': '[email protected]', 'phone': '18600000034'}, {'username': 'test0035', 'password': 'pwd0035', 'email': '[email protected]', 'phone': '18600000035'}, {'username': 'test0036', 'password': 'pwd0036', 'email': '[email protected]', 'phone': '18600000036'}, {'username': 'test0037', 'password': 'pwd0037', 'email': '[email protected]', 'phone': '18600000037'}, {'username': 'test0038', 'password': 'pwd0038', 'email': '[email protected]', 'phone': '18600000038'}, {'username': 'test0039', 'password': 'pwd0039', 'email': '[email protected]', 'phone': '18600000039'}, {'username': 'test0040', 'password': 'pwd0040', 'email': '[email protected]', 'phone': '18600000040'}, {'username': 'test0041', 'password': 'pwd0041', 'email': '[email protected]', 'phone': '18600000041'}, {'username': 'test0042', 'password': 'pwd0042', 'email': '[email protected]', 'phone': '18600000042'}, {'username': 'test0043', 'password': 'pwd0043', 'email': '[email protected]', 'phone': '18600000043'}, {'username': 'test0044', 'password': 'pwd0044', 'email': '[email protected]', 'phone': '18600000044'}, {'username': 'test0045', 'password': 'pwd0045', 'email': '[email protected]', 'phone': '18600000045'}, {'username': 'test0046', 'password': 'pwd0046', 'email': '[email protected]', 'phone': '18600000046'}, {'username': 'test0047', 'password': 'pwd0047', 'email': '[email protected]', 'phone': '18600000047'}, {'username': 'test0048', 'password': 'pwd0048', 'email': '[email protected]', 'phone': '18600000048'}, {'username': 'test0049', 'password': 'pwd0049', 'email': '[email protected]', 'phone': '18600000049'}, {'username': 'test0050', 'password': 'pwd0050', 'email': '[email protected]', 'phone': '18600000050'}, {'username': 'test0051', 'password': 'pwd0051', 'email': '[email protected]', 'phone': '18600000051'}, {'username': 'test0052', 'password': 'pwd0052', 'email': '[email protected]', 'phone': '18600000052'}, {'username': 'test0053', 'password': 'pwd0053', 'email': '[email protected]', 'phone': '18600000053'}, {'username': 'test0054', 'password': 'pwd0054', 'email': '[email protected]', 'phone': '18600000054'}, {'username': 'test0055', 'password': 'pwd0055', 'email': '[email protected]', 'phone': '18600000055'}, {'username': 'test0056', 'password': 'pwd0056', 'email': '[email protected]', 'phone': '18600000056'}, {'username': 'test0057', 'password': 'pwd0057', 'email': '[email protected]', 'phone': '18600000057'}, {'username': 'test0058', 'password': 'pwd0058', 'email': '[email protected]', 'phone': '18600000058'}, {'username': 'test0059', 'password': 'pwd0059', 'email': '[email protected]', 'phone': '18600000059'}, {'username': 'test0060', 'password': 'pwd0060', 'email': '[email protected]', 'phone': '18600000060'}, {'username': 'test0061', 'password': 'pwd0061', 'email': '[email protected]', 'phone': '18600000061'}, {'username': 'test0062', 'password': 'pwd0062', 'email': '[email protected]', 'phone': '18600000062'}, {'username': 'test0063', 'password': 'pwd0063', 'email': '[email protected]', 'phone': '18600000063'}, {'username': 'test0064', 'password': 'pwd0064', 'email': '[email protected]', 'phone': '18600000064'}, {'username': 'test0065', 'password': 'pwd0065', 'email': '[email protected]', 'phone': '18600000065'}, {'username': 'test0066', 'password': 'pwd0066', 'email': '[email protected]', 'phone': '18600000066'}, {'username': 'test0067', 'password': 'pwd0067', 'email': '[email protected]', 'phone': '18600000067'}, {'username': 'test0068', 'password': 'pwd0068', 'email': '[email protected]', 'phone': '18600000068'}, {'username': 'test0069', 'password': 'pwd0069', 'email': '[email protected]', 'phone': '18600000069'}, {'username': 'test0070', 'password': 'pwd0070', 'email': '[email protected]', 'phone': '18600000070'}, {'username': 'test0071', 'password': 'pwd0071', 'email': '[email protected]', 'phone': '18600000071'}, {'username': 'test0072', 'password': 'pwd0072', 'email': '[email protected]', 'phone': '18600000072'}, {'username': 'test0073', 'password': 'pwd0073', 'email': '[email protected]', 'phone': '18600000073'}, {'username': 'test0074', 'password': 'pwd0074', 'email': '[email protected]', 'phone': '18600000074'}, {'username': 'test0075', 'password': 'pwd0075', 'email': '[email protected]', 'phone': '18600000075'}, {'username': 'test0076', 'password': 'pwd0076', 'email': '[email protected]', 'phone': '18600000076'}, {'username': 'test0077', 'password': 'pwd0077', 'email': '[email protected]', 'phone': '18600000077'}, {'username': 'test0078', 'password': 'pwd0078', 'email': '[email protected]', 'phone': '18600000078'}, {'username': 'test0079', 'password': 'pwd0079', 'email': '[email protected]', 'phone': '18600000079'}, {'username': 'test0080', 'password': 'pwd0080', 'email': '[email protected]', 'phone': '18600000080'}, {'username': 'test0081', 'password': 'pwd0081', 'email': '[email protected]', 'phone': '18600000081'}, {'username': 'test0082', 'password': 'pwd0082', 'email': '[email protected]', 'phone': '18600000082'}, {'username': 'test0083', 'password': 'pwd0083', 'email': '[email protected]', 'phone': '18600000083'}, {'username': 'test0084', 'password': 'pwd0084', 'email': '[email protected]', 'phone': '18600000084'}, {'username': 'test0085', 'password': 'pwd0085', 'email': '[email protected]', 'phone': '18600000085'}, {'username': 'test0086', 'password': 'pwd0086', 'email': '[email protected]', 'phone': '18600000086'}, {'username': 'test0087', 'password': 'pwd0087', 'email': '[email protected]', 'phone': '18600000087'}, {'username': 'test0088', 'password': 'pwd0088', 'email': '[email protected]', 'phone': '18600000088'}, {'username': 'test0089', 'password': 'pwd0089', 'email': '[email protected]', 'phone': '18600000089'}, {'username': 'test0090', 'password': 'pwd0090', 'email': '[email protected]', 'phone': '18600000090'}, {'username': 'test0091', 'password': 'pwd0091', 'email': '[email protected]', 'phone': '18600000091'}, {'username': 'test0092', 'password': 'pwd0092', 'email': '[email protected]', 'phone': '18600000092'}, {'username': 'test0093', 'password': 'pwd0093', 'email': '[email protected]', 'phone': '18600000093'}, {'username': 'test0094', 'password': 'pwd0094', 'email': '[email protected]', 'phone': '18600000094'}, {'username': 'test0095', 'password': 'pwd0095', 'email': '[email protected]', 'phone': '18600000095'}, {'username': 'test0096', 'password': 'pwd0096', 'email': '[email protected]', 'phone': '18600000096'}, {'username': 'test0097', 'password': 'pwd0097', 'email': '[email protected]', 'phone': '18600000097'}, {'username': 'test0098', 'password': 'pwd0098', 'email': '[email protected]', 'phone': '18600000098'}, {'username': 'test0099', 'password': 'pwd0099', 'email': '[email protected]', 'phone': '18600000099'}]

Process finished with exit code 0

  这里我写了三种方法,推荐第三种,至于为啥写这么多,权当复习一下python的语法。

  测试数据准备好了,可以添加到队列中:

  法1:

result_list = []
for index in range(100):
    data = {
            "username": "test%04d" % index,
            "password": "pwd%04d" % index,
            "email": "test%[email protected]" % index,
            "phone": "186%08d" % index,
        }
    result_list.append(data)
# print(result_list)


user_data_queue = queue.Queue()
for index in result_list:
    user_data_queue.put_nowait(index)
    print(index)
    print(user_data_queue.get())

  结果:

{'username': 'test0000', 'password': 'pwd0000', 'email': '[email protected]', 'phone': '18600000000'}
{'username': 'test0000', 'password': 'pwd0000', 'email': '[email protected]', 'phone': '18600000000'}
{'username': 'test0001', 'password': 'pwd0001', 'email': '[email protected]', 'phone': '18600000001'}
{'username': 'test0001', 'password': 'pwd0001', 'email': '[email protected]', 'phone': '18600000001'}
{'username': 'test0002', 'password': 'pwd0002', 'email': '[email protected]', 'phone': '18600000002'}
{'username': 'test0002', 'password': 'pwd0002', 'email': '[email protected]', 'phone': '18600000002'}
{'username': 'test0003', 'password': 'pwd0003', 'email': '[email protected]', 'phone': '18600000003'}
{'username': 'test0003', 'password': 'pwd0003', 'email': '[email protected]', 'phone': '18600000003'}
{'username': 'test0004', 'password': 'pwd0004', 'email': '[email protected]', 'phone': '18600000004'}
{'username': 'test0004', 'password': 'pwd0004', 'email': '[email protected]', 'phone': '18600000004'}
{'username': 'test0005', 'password': 'pwd0005', 'email': '[email protected]', 'phone': '18600000005'}
{'username': 'test0005', 'password': 'pwd0005', 'email': '[email protected]', 'phone': '18600000005'}
{'username': 'test0006', 'password': 'pwd0006', 'email': '[email protected]', 'phone': '18600000006'}
{'username': 'test0006', 'password': 'pwd0006', 'email': '[email protected]', 'phone': '18600000006'}
{'username': 'test0007', 'password': 'pwd0007', 'email': '[email protected]', 'phone': '18600000007'}
{'username': 'test0007', 'password': 'pwd0007', 'email': '[email protected]', 'phone': '18600000007'}
{'username': 'test0008', 'password': 'pwd0008', 'email': '[email protected]', 'phone': '18600000008'}
{'username': 'test0008', 'password': 'pwd0008', 'email': '[email protected]', 'phone': '18600000008'}
{'username': 'test0009', 'password': 'pwd0009', 'email': '[email protected]', 'phone': '18600000009'}
{'username': 'test0009', 'password': 'pwd0009', 'email': '[email protected]', 'phone': '18600000009'}
{'username': 'test0010', 'password': 'pwd0010', 'email': '[email protected]', 'phone': '18600000010'}
{'username': 'test0010', 'password': 'pwd0010', 'email': '[email protected]', 'phone': '18600000010'}
{'username': 'test0011', 'password': 'pwd0011', 'email': '[email protected]', 'phone': '18600000011'}
{'username': 'test0011', 'password': 'pwd0011', 'email': '[email protected]', 'phone': '18600000011'}
{'username': 'test0012', 'password': 'pwd0012', 'email': '[email protected]', 'phone': '18600000012'}
{'username': 'test0012', 'password': 'pwd0012', 'email': '[email protected]', 'phone': '18600000012'}
{'username': 'test0013', 'password': 'pwd0013', 'email': '[email protected]', 'phone': '18600000013'}
{'username': 'test0013', 'password': 'pwd0013', 'email': '[email protected]', 'phone': '18600000013'}
{'username': 'test0014', 'password': 'pwd0014', 'email': '[email protected]', 'phone': '18600000014'}
{'username': 'test0014', 'password': 'pwd0014', 'email': '[email protected]', 'phone': '18600000014'}
{'username': 'test0015', 'password': 'pwd0015', 'email': '[email protected]', 'phone': '18600000015'}
{'username': 'test0015', 'password': 'pwd0015', 'email': '[email protected]', 'phone': '18600000015'}
{'username': 'test0016', 'password': 'pwd0016', 'email': '[email protected]', 'phone': '18600000016'}
{'username': 'test0016', 'password': 'pwd0016', 'email': '[email protected]', 'phone': '18600000016'}
{'username': 'test0017', 'password': 'pwd0017', 'email': '[email protected]', 'phone': '18600000017'}
{'username': 'test0017', 'password': 'pwd0017', 'email': '[email protected]', 'phone': '18600000017'}
{'username': 'test0018', 'password': 'pwd0018', 'email': '[email protected]', 'phone': '18600000018'}
{'username': 'test0018', 'password': 'pwd0018', 'email': '[email protected]', 'phone': '18600000018'}
{'username': 'test0019', 'password': 'pwd0019', 'email': '[email protected]', 'phone': '18600000019'}
{'username': 'test0019', 'password': 'pwd0019', 'email': '[email protected]', 'phone': '18600000019'}
{'username': 'test0020', 'password': 'pwd0020', 'email': '[email protected]', 'phone': '18600000020'}
{'username': 'test0020', 'password': 'pwd0020', 'email': '[email protected]', 'phone': '18600000020'}
{'username': 'test0021', 'password': 'pwd0021', 'email': '[email protected]', 'phone': '18600000021'}
{'username': 'test0021', 'password': 'pwd0021', 'email': '[email protected]', 'phone': '18600000021'}
{'username': 'test0022', 'password': 'pwd0022', 'email': '[email protected]', 'phone': '18600000022'}
{'username': 'test0022', 'password': 'pwd0022', 'email': '[email protected]', 'phone': '18600000022'}
{'username': 'test0023', 'password': 'pwd0023', 'email': '[email protected]', 'phone': '18600000023'}
{'username': 'test0023', 'password': 'pwd0023', 'email': '[email protected]', 'phone': '18600000023'}
{'username': 'test0024', 'password': 'pwd0024', 'email': '[email protected]', 'phone': '18600000024'}
{'username': 'test0024', 'password': 'pwd0024', 'email': '[email protected]', 'phone': '18600000024'}
{'username': 'test0025', 'password': 'pwd0025', 'email': '[email protected]', 'phone': '18600000025'}
{'username': 'test0025', 'password': 'pwd0025', 'email': '[email protected]', 'phone': '18600000025'}
{'username': 'test0026', 'password': 'pwd0026', 'email': '[email protected]', 'phone': '18600000026'}
{'username': 'test0026', 'password': 'pwd0026', 'email': '[email protected]', 'phone': '18600000026'}
{'username': 'test0027', 'password': 'pwd0027', 'email': '[email protected]', 'phone': '18600000027'}
{'username': 'test0027', 'password': 'pwd0027', 'email': '[email protected]', 'phone': '18600000027'}
{'username': 'test0028', 'password': 'pwd0028', 'email': '[email protected]', 'phone': '18600000028'}
{'username': 'test0028', 'password': 'pwd0028', 'email': '[email protected]', 'phone': '18600000028'}
{'username': 'test0029', 'password': 'pwd0029', 'email': '[email protected]', 'phone': '18600000029'}
{'username': 'test0029', 'password': 'pwd0029', 'email': '[email protected]', 'phone': '18600000029'}
{'username': 'test0030', 'password': 'pwd0030', 'email': '[email protected]', 'phone': '18600000030'}
{'username': 'test0030', 'password': 'pwd0030', 'email': '[email protected]', 'phone': '18600000030'}
{'username': 'test0031', 'password': 'pwd0031', 'email': '[email protected]', 'phone': '18600000031'}
{'username': 'test0031', 'password': 'pwd0031', 'email': '[email protected]', 'phone': '18600000031'}
{'username': 'test0032', 'password': 'pwd0032', 'email': '[email protected]', 'phone': '18600000032'}
{'username': 'test0032', 'password': 'pwd0032', 'email': '[email protected]', 'phone': '18600000032'}
{'username': 'test0033', 'password': 'pwd0033', 'email': '[email protected]', 'phone': '18600000033'}
{'username': 'test0033', 'password': 'pwd0033', 'email': '[email protected]', 'phone': '18600000033'}
{'username': 'test0034', 'password': 'pwd0034', 'email': '[email protected]', 'phone': '18600000034'}
{'username': 'test0034', 'password': 'pwd0034', 'email': '[email protected]', 'phone': '18600000034'}
{'username': 'test0035', 'password': 'pwd0035', 'email': '[email protected]', 'phone': '18600000035'}
{'username': 'test0035', 'password': 'pwd0035', 'email': '[email protected]', 'phone': '18600000035'}
{'username': 'test0036', 'password': 'pwd0036', 'email': '[email protected]', 'phone': '18600000036'}
{'username': 'test0036', 'password': 'pwd0036', 'email': '[email protected]', 'phone': '18600000036'}
{'username': 'test0037', 'password': 'pwd0037', 'email': '[email protected]', 'phone': '18600000037'}
{'username': 'test0037', 'password': 'pwd0037', 'email': '[email protected]', 'phone': '18600000037'}
{'username': 'test0038', 'password': 'pwd0038', 'email': '[email protected]', 'phone': '18600000038'}
{'username': 'test0038', 'password': 'pwd0038', 'email': '[email protected]', 'phone': '18600000038'}
{'username': 'test0039', 'password': 'pwd0039', 'email': '[email protected]', 'phone': '18600000039'}
{'username': 'test0039', 'password': 'pwd0039', 'email': '[email protected]', 'phone': '18600000039'}
{'username': 'test0040', 'password': 'pwd0040', 'email': '[email protected]', 'phone': '18600000040'}
{'username': 'test0040', 'password': 'pwd0040', 'email': '[email protected]', 'phone': '18600000040'}
{'username': 'test0041', 'password': 'pwd0041', 'email': '[email protected]', 'phone': '18600000041'}
{'username': 'test0041', 'password': 'pwd0041', 'email': '[email protected]', 'phone': '18600000041'}
{'username': 'test0042', 'password': 'pwd0042', 'email': '[email protected]', 'phone': '18600000042'}
{'username': 'test0042', 'password': 'pwd0042', 'email': '[email protected]', 'phone': '18600000042'}
{'username': 'test0043', 'password': 'pwd0043', 'email': '[email protected]', 'phone': '18600000043'}
{'username': 'test0043', 'password': 'pwd0043', 'email': '[email protected]', 'phone': '18600000043'}
{'username': 'test0044', 'password': 'pwd0044', 'email': '[email protected]', 'phone': '18600000044'}
{'username': 'test0044', 'password': 'pwd0044', 'email': '[email protected]', 'phone': '18600000044'}
{'username': 'test0045', 'password': 'pwd0045', 'email': '[email protected]', 'phone': '18600000045'}
{'username': 'test0045', 'password': 'pwd0045', 'email': '[email protected]', 'phone': '18600000045'}
{'username': 'test0046', 'password': 'pwd0046', 'email': '[email protected]', 'phone': '18600000046'}
{'username': 'test0046', 'password': 'pwd0046', 'email': '[email protected]', 'phone': '18600000046'}
{'username': 'test0047', 'password': 'pwd0047', 'email': '[email protected]', 'phone': '18600000047'}
{'username': 'test0047', 'password': 'pwd0047', 'email': '[email protected]', 'phone': '18600000047'}
{'username': 'test0048', 'password': 'pwd0048', 'email': '[email protected]', 'phone': '18600000048'}
{'username': 'test0048', 'password': 'pwd0048', 'email': '[email protected]', 'phone': '18600000048'}
{'username': 'test0049', 'password': 'pwd0049', 'email': '[email protected]', 'phone': '18600000049'}
{'username': 'test0049', 'password': 'pwd0049', 'email': '[email protected]', 'phone': '18600000049'}
{'username': 'test0050', 'password': 'pwd0050', 'email': '[email protected]', 'phone': '18600000050'}
{'username': 'test0050', 'password': 'pwd0050', 'email': '[email protected]', 'phone': '18600000050'}
{'username': 'test0051', 'password': 'pwd0051', 'email': '[email protected]', 'phone': '18600000051'}
{'username': 'test0051', 'password': 'pwd0051', 'email': '[email protected]', 'phone': '18600000051'}
{'username': 'test0052', 'password': 'pwd0052', 'email': '[email protected]', 'phone': '18600000052'}
{'username': 'test0052', 'password': 'pwd0052', 'email': '[email protected]', 'phone': '18600000052'}
{'username': 'test0053', 'password': 'pwd0053', 'email': '[email protected]', 'phone': '18600000053'}
{'username': 'test0053', 'password': 'pwd0053', 'email': '[email protected]', 'phone': '18600000053'}
{'username': 'test0054', 'password': 'pwd0054', 'email': '[email protected]', 'phone': '18600000054'}
{'username': 'test0054', 'password': 'pwd0054', 'email': '[email protected]', 'phone': '18600000054'}
{'username': 'test0055', 'password': 'pwd0055', 'email': '[email protected]', 'phone': '18600000055'}
{'username': 'test0055', 'password': 'pwd0055', 'email': '[email protected]', 'phone': '18600000055'}
{'username': 'test0056', 'password': 'pwd0056', 'email': '[email protected]', 'phone': '18600000056'}
{'username': 'test0056', 'password': 'pwd0056', 'email': '[email protected]', 'phone': '18600000056'}
{'username': 'test0057', 'password': 'pwd0057', 'email': '[email protected]', 'phone': '18600000057'}
{'username': 'test0057', 'password': 'pwd0057', 'email': '[email protected]', 'phone': '18600000057'}
{'username': 'test0058', 'password': 'pwd0058', 'email': '[email protected]', 'phone': '18600000058'}
{'username': 'test0058', 'password': 'pwd0058', 'email': '[email protected]', 'phone': '18600000058'}
{'username': 'test0059', 'password': 'pwd0059', 'email': '[email protected]', 'phone': '18600000059'}
{'username': 'test0059', 'password': 'pwd0059', 'email': '[email protected]', 'phone': '18600000059'}
{'username': 'test0060', 'password': 'pwd0060', 'email': '[email protected]', 'phone': '18600000060'}
{'username': 'test0060', 'password': 'pwd0060', 'email': '[email protected]', 'phone': '18600000060'}
{'username': 'test0061', 'password': 'pwd0061', 'email': '[email protected]', 'phone': '18600000061'}
{'username': 'test0061', 'password': 'pwd0061', 'email': '[email protected]', 'phone': '18600000061'}
{'username': 'test0062', 'password': 'pwd0062', 'email': '[email protected]', 'phone': '18600000062'}
{'username': 'test0062', 'password': 'pwd0062', 'email': '[email protected]', 'phone': '18600000062'}
{'username': 'test0063', 'password': 'pwd0063', 'email': '[email protected]', 'phone': '18600000063'}
{'username': 'test0063', 'password': 'pwd0063', 'email': '[email protected]', 'phone': '18600000063'}
{'username': 'test0064', 'password': 'pwd0064', 'email': '[email protected]', 'phone': '18600000064'}
{'username': 'test0064', 'password': 'pwd0064', 'email': '[email protected]', 'phone': '18600000064'}
{'username': 'test0065', 'password': 'pwd0065', 'email': '[email protected]', 'phone': '18600000065'}
{'username': 'test0065', 'password': 'pwd0065', 'email': '[email protected]', 'phone': '18600000065'}
{'username': 'test0066', 'password': 'pwd0066', 'email': '[email protected]', 'phone': '18600000066'}
{'username': 'test0066', 'password': 'pwd0066', 'email': '[email protected]', 'phone': '18600000066'}
{'username': 'test0067', 'password': 'pwd0067', 'email': '[email protected]', 'phone': '18600000067'}
{'username': 'test0067', 'password': 'pwd0067', 'email': '[email protected]', 'phone': '18600000067'}
{'username': 'test0068', 'password': 'pwd0068', 'email': '[email protected]', 'phone': '18600000068'}
{'username': 'test0068', 'password': 'pwd0068', 'email': '[email protected]', 'phone': '18600000068'}
{'username': 'test0069', 'password': 'pwd0069', 'email': '[email protected]', 'phone': '18600000069'}
{'username': 'test0069', 'password': 'pwd0069', 'email': '[email protected]', 'phone': '18600000069'}
{'username': 'test0070', 'password': 'pwd0070', 'email': '[email protected]', 'phone': '18600000070'}
{'username': 'test0070', 'password': 'pwd0070', 'email': '[email protected]', 'phone': '18600000070'}
{'username': 'test0071', 'password': 'pwd0071', 'email': '[email protected]', 'phone': '18600000071'}
{'username': 'test0071', 'password': 'pwd0071', 'email': '[email protected]', 'phone': '18600000071'}
{'username': 'test0072', 'password': 'pwd0072', 'email': '[email protected]', 'phone': '18600000072'}
{'username': 'test0072', 'password': 'pwd0072', 'email': '[email protected]', 'phone': '18600000072'}
{'username': 'test0073', 'password': 'pwd0073', 'email': '[email protected]', 'phone': '18600000073'}
{'username': 'test0073', 'password': 'pwd0073', 'email': '[email protected]', 'phone': '18600000073'}
{'username': 'test0074', 'password': 'pwd0074', 'email': '[email protected]', 'phone': '18600000074'}
{'username': 'test0074', 'password': 'pwd0074', 'email': '[email protected]', 'phone': '18600000074'}
{'username': 'test0075', 'password': 'pwd0075', 'email': '[email protected]', 'phone': '18600000075'}
{'username': 'test0075', 'password': 'pwd0075', 'email': '[email protected]', 'phone': '18600000075'}
{'username': 'test0076', 'password': 'pwd0076', 'email': '[email protected]', 'phone': '18600000076'}
{'username': 'test0076', 'password': 'pwd0076', 'email': '[email protected]', 'phone': '18600000076'}
{'username': 'test0077', 'password': 'pwd0077', 'email': '[email protected]', 'phone': '18600000077'}
{'username': 'test0077', 'password': 'pwd0077', 'email': '[email protected]', 'phone': '18600000077'}
{'username': 'test0078', 'password': 'pwd0078', 'email': '[email protected]', 'phone': '18600000078'}
{'username': 'test0078', 'password': 'pwd0078', 'email': '[email protected]', 'phone': '18600000078'}
{'username': 'test0079', 'password': 'pwd0079', 'email': '[email protected]', 'phone': '18600000079'}
{'username': 'test0079', 'password': 'pwd0079', 'email': '[email protected]', 'phone': '18600000079'}
{'username': 'test0080', 'password': 'pwd0080', 'email': '[email protected]', 'phone': '18600000080'}
{'username': 'test0080', 'password': 'pwd0080', 'email': '[email protected]', 'phone': '18600000080'}
{'username': 'test0081', 'password': 'pwd0081', 'email': '[email protected]', 'phone': '18600000081'}
{'username': 'test0081', 'password': 'pwd0081', 'email': '[email protected]', 'phone': '18600000081'}
{'username': 'test0082', 'password': 'pwd0082', 'email': '[email protected]', 'phone': '18600000082'}
{'username': 'test0082', 'password': 'pwd0082', 'email': '[email protected]', 'phone': '18600000082'}
{'username': 'test0083', 'password': 'pwd0083', 'email': '[email protected]', 'phone': '18600000083'}
{'username': 'test0083', 'password': 'pwd0083', 'email': '[email protected]', 'phone': '18600000083'}
{'username': 'test0084', 'password': 'pwd0084', 'email': '[email protected]', 'phone': '18600000084'}
{'username': 'test0084', 'password': 'pwd0084', 'email': '[email protected]', 'phone': '18600000084'}
{'username': 'test0085', 'password': 'pwd0085', 'email': '[email protected]', 'phone': '18600000085'}
{'username': 'test0085', 'password': 'pwd0085', 'email': '[email protected]', 'phone': '18600000085'}
{'username': 'test0086', 'password': 'pwd0086', 'email': '[email protected]', 'phone': '18600000086'}
{'username': 'test0086', 'password': 'pwd0086', 'email': '[email protected]', 'phone': '18600000086'}
{'username': 'test0087', 'password': 'pwd0087', 'email': '[email protected]', 'phone': '18600000087'}
{'username': 'test0087', 'password': 'pwd0087', 'email': '[email protected]', 'phone': '18600000087'}
{'username': 'test0088', 'password': 'pwd0088', 'email': '[email protected]', 'phone': '18600000088'}
{'username': 'test0088', 'password': 'pwd0088', 'email': '[email protected]', 'phone': '18600000088'}
{'username': 'test0089', 'password': 'pwd0089', 'email': '[email protected]', 'phone': '18600000089'}
{'username': 'test0089', 'password': 'pwd0089', 'email': '[email protected]', 'phone': '18600000089'}
{'username': 'test0090', 'password': 'pwd0090', 'email': '[email protected]', 'phone': '18600000090'}
{'username': 'test0090', 'password': 'pwd0090', 'email': '[email protected]', 'phone': '18600000090'}
{'username': 'test0091', 'password': 'pwd0091', 'email': '[email protected]', 'phone': '18600000091'}
{'username': 'test0091', 'password': 'pwd0091', 'email': '[email protected]', 'phone': '18600000091'}
{'username': 'test0092', 'password': 'pwd0092', 'email': '[email protected]', 'phone': '18600000092'}
{'username': 'test0092', 'password': 'pwd0092', 'email': '[email protected]', 'phone': '18600000092'}
{'username': 'test0093', 'password': 'pwd0093', 'email': '[email protected]', 'phone': '18600000093'}
{'username': 'test0093', 'password': 'pwd0093', 'email': '[email protected]', 'phone': '18600000093'}
{'username': 'test0094', 'password': 'pwd0094', 'email': '[email protected]', 'phone': '18600000094'}
{'username': 'test0094', 'password': 'pwd0094', 'email': '[email protected]', 'phone': '18600000094'}
{'username': 'test0095', 'password': 'pwd0095', 'email': '[email protected]', 'phone': '18600000095'}
{'username': 'test0095', 'password': 'pwd0095', 'email': '[email protected]', 'phone': '18600000095'}
{'username': 'test0096', 'password': 'pwd0096', 'email': '[email protected]', 'phone': '18600000096'}
{'username': 'test0096', 'password': 'pwd0096', 'email': '[email protected]', 'phone': '18600000096'}
{'username': 'test0097', 'password': 'pwd0097', 'email': '[email protected]', 'phone': '18600000097'}
{'username': 'test0097', 'password': 'pwd0097', 'email': '[email protected]', 'phone': '18600000097'}
{'username': 'test0098', 'password': 'pwd0098', 'email': '[email protected]', 'phone': '18600000098'}
{'username': 'test0098', 'password': 'pwd0098', 'email': '[email protected]', 'phone': '18600000098'}
{'username': 'test0099', 'password': 'pwd0099', 'email': '[email protected]', 'phone': '18600000099'}
{'username': 'test0099', 'password': 'pwd0099', 'email': '[email protected]', 'phone': '18600000099'}

Process finished with exit code 0

  

  显然这样写有点啰嗦,改一下:

user_data_queue = queue.Queue()
for index in range(100):
    data = '''{
        "username": "test%04d",
        "password": "pwd%04d",
        "email": "test%[email protected]",
        "phone": "186%08d",
    }'''%(index,index,index ,index)
    user_data_queue.put_nowait(data.replace(' ','').replace('\n',''))
    print(user_data_queue.get())

  结果:

{"username":"test0000","password":"pwd0000","email":"[email protected]","phone":"18600000000",}
{"username":"test0001","password":"pwd0001","email":"[email protected]","phone":"18600000001",}
{"username":"test0002","password":"pwd0002","email":"[email protected]","phone":"18600000002",}
{"username":"test0003","password":"pwd0003","email":"[email protected]","phone":"18600000003",}
{"username":"test0004","password":"pwd0004","email":"[email protected]","phone":"18600000004",}
{"username":"test0005","password":"pwd0005","email":"[email protected]","phone":"18600000005",}
{"username":"test0006","password":"pwd0006","email":"[email protected]","phone":"18600000006",}
{"username":"test0007","password":"pwd0007","email":"[email protected]","phone":"18600000007",}
{"username":"test0008","password":"pwd0008","email":"[email protected]","phone":"18600000008",}
{"username":"test0009","password":"pwd0009","email":"[email protected]","phone":"18600000009",}
{"username":"test0010","password":"pwd0010","email":"[email protected]","phone":"18600000010",}
{"username":"test0011","password":"pwd0011","email":"[email protected]","phone":"18600000011",}
{"username":"test0012","password":"pwd0012","email":"[email protected]","phone":"18600000012",}
{"username":"test0013","password":"pwd0013","email":"[email protected]","phone":"18600000013",}
{"username":"test0014","password":"pwd0014","email":"[email protected]","phone":"18600000014",}
{"username":"test0015","password":"pwd0015","email":"[email protected]","phone":"18600000015",}
{"username":"test0016","password":"pwd0016","email":"[email protected]","phone":"18600000016",}
{"username":"test0017","password":"pwd0017","email":"[email protected]","phone":"18600000017",}
{"username":"test0018","password":"pwd0018","email":"[email protected]","phone":"18600000018",}
{"username":"test0019","password":"pwd0019","email":"[email protected]","phone":"18600000019",}
{"username":"test0020","password":"pwd0020","email":"[email protected]","phone":"18600000020",}
{"username":"test0021","password":"pwd0021","email":"[email protected]","phone":"18600000021",}
{"username":"test0022","password":"pwd0022","email":"[email protected]","phone":"18600000022",}
{"username":"test0023","password":"pwd0023","email":"[email protected]","phone":"18600000023",}
{"username":"test0024","password":"pwd0024","email":"[email protected]","phone":"18600000024",}
{"username":"test0025","password":"pwd0025","email":"[email protected]","phone":"18600000025",}
{"username":"test0026","password":"pwd0026","email":"[email protected]","phone":"18600000026",}
{"username":"test0027","password":"pwd0027","email":"[email protected]","phone":"18600000027",}
{"username":"test0028","password":"pwd0028","email":"[email protected]","phone":"18600000028",}
{"username":"test0029","password":"pwd0029","email":"[email protected]","phone":"18600000029",}
{"username":"test0030","password":"pwd0030","email":"[email protected]","phone":"18600000030",}
{"username":"test0031","password":"pwd0031","email":"[email protected]","phone":"18600000031",}
{"username":"test0032","password":"pwd0032","email":"[email protected]","phone":"18600000032",}
{"username":"test0033","password":"pwd0033","email":"[email protected]","phone":"18600000033",}
{"username":"test0034","password":"pwd0034","email":"[email protected]","phone":"18600000034",}
{"username":"test0035","password":"pwd0035","email":"[email protected]","phone":"18600000035",}
{"username":"test0036","password":"pwd0036","email":"[email protected]","phone":"18600000036",}
{"username":"test0037","password":"pwd0037","email":"[email protected]","phone":"18600000037",}
{"username":"test0038","password":"pwd0038","email":"[email protected]","phone":"18600000038",}
{"username":"test0039","password":"pwd0039","email":"[email protected]","phone":"18600000039",}
{"username":"test0040","password":"pwd0040","email":"[email protected]","phone":"18600000040",}
{"username":"test0041","password":"pwd0041","email":"[email protected]","phone":"18600000041",}
{"username":"test0042","password":"pwd0042","email":"[email protected]","phone":"18600000042",}
{"username":"test0043","password":"pwd0043","email":"[email protected]","phone":"18600000043",}
{"username":"test0044","password":"pwd0044","email":"[email protected]","phone":"18600000044",}
{"username":"test0045","password":"pwd0045","email":"[email protected]","phone":"18600000045",}
{"username":"test0046","password":"pwd0046","email":"[email protected]","phone":"18600000046",}
{"username":"test0047","password":"pwd0047","email":"[email protected]","phone":"18600000047",}
{"username":"test0048","password":"pwd0048","email":"[email protected]","phone":"18600000048",}
{"username":"test0049","password":"pwd0049","email":"[email protected]","phone":"18600000049",}
{"username":"test0050","password":"pwd0050","email":"[email protected]","phone":"18600000050",}
{"username":"test0051","password":"pwd0051","email":"[email protected]","phone":"18600000051",}
{"username":"test0052","password":"pwd0052","email":"[email protected]","phone":"18600000052",}
{"username":"test0053","password":"pwd0053","email":"[email protected]","phone":"18600000053",}
{"username":"test0054","password":"pwd0054","email":"[email protected]","phone":"18600000054",}
{"username":"test0055","password":"pwd0055","email":"[email protected]","phone":"18600000055",}
{"username":"test0056","password":"pwd0056","email":"[email protected]","phone":"18600000056",}
{"username":"test0057","password":"pwd0057","email":"[email protected]","phone":"18600000057",}
{"username":"test0058","password":"pwd0058","email":"[email protected]","phone":"18600000058",}
{"username":"test0059","password":"pwd0059","email":"[email protected]","phone":"18600000059",}
{"username":"test0060","password":"pwd0060","email":"[email protected]","phone":"18600000060",}
{"username":"test0061","password":"pwd0061","email":"[email protected]","phone":"18600000061",}
{"username":"test0062","password":"pwd0062","email":"[email protected]","phone":"18600000062",}
{"username":"test0063","password":"pwd0063","email":"[email protected]","phone":"18600000063",}
{"username":"test0064","password":"pwd0064","email":"[email protected]","phone":"18600000064",}
{"username":"test0065","password":"pwd0065","email":"[email protected]","phone":"18600000065",}
{"username":"test0066","password":"pwd0066","email":"[email protected]","phone":"18600000066",}
{"username":"test0067","password":"pwd0067","email":"[email protected]","phone":"18600000067",}
{"username":"test0068","password":"pwd0068","email":"[email protected]","phone":"18600000068",}
{"username":"test0069","password":"pwd0069","email":"[email protected]","phone":"18600000069",}
{"username":"test0070","password":"pwd0070","email":"[email protected]","phone":"18600000070",}
{"username":"test0071","password":"pwd0071","email":"[email protected]","phone":"18600000071",}
{"username":"test0072","password":"pwd0072","email":"[email protected]","phone":"18600000072",}
{"username":"test0073","password":"pwd0073","email":"[email protected]","phone":"18600000073",}
{"username":"test0074","password":"pwd0074","email":"[email protected]","phone":"18600000074",}
{"username":"test0075","password":"pwd0075","email":"[email protected]","phone":"18600000075",}
{"username":"test0076","password":"pwd0076","email":"[email protected]","phone":"18600000076",}
{"username":"test0077","password":"pwd0077","email":"[email protected]","phone":"18600000077",}
{"username":"test0078","password":"pwd0078","email":"[email protected]","phone":"18600000078",}
{"username":"test0079","password":"pwd0079","email":"[email protected]","phone":"18600000079",}
{"username":"test0080","password":"pwd0080","email":"[email protected]","phone":"18600000080",}
{"username":"test0081","password":"pwd0081","email":"[email protected]","phone":"18600000081",}
{"username":"test0082","password":"pwd0082","email":"[email protected]","phone":"18600000082",}
{"username":"test0083","password":"pwd0083","email":"[email protected]","phone":"18600000083",}
{"username":"test0084","password":"pwd0084","email":"[email protected]","phone":"18600000084",}
{"username":"test0085","password":"pwd0085","email":"[email protected]","phone":"18600000085",}
{"username":"test0086","password":"pwd0086","email":"[email protected]","phone":"18600000086",}
{"username":"test0087","password":"pwd0087","email":"[email protected]","phone":"18600000087",}
{"username":"test0088","password":"pwd0088","email":"[email protected]","phone":"18600000088",}
{"username":"test0089","password":"pwd0089","email":"[email protected]","phone":"18600000089",}
{"username":"test0090","password":"pwd0090","email":"[email protected]","phone":"18600000090",}
{"username":"test0091","password":"pwd0091","email":"[email protected]","phone":"18600000091",}
{"username":"test0092","password":"pwd0092","email":"[email protected]","phone":"18600000092",}
{"username":"test0093","password":"pwd0093","email":"[email protected]","phone":"18600000093",}
{"username":"test0094","password":"pwd0094","email":"[email protected]","phone":"18600000094",}
{"username":"test0095","password":"pwd0095","email":"[email protected]","phone":"18600000095",}
{"username":"test0096","password":"pwd0096","email":"[email protected]","phone":"18600000096",}
{"username":"test0097","password":"pwd0097","email":"[email protected]","phone":"18600000097",}
{"username":"test0098","password":"pwd0098","email":"[email protected]","phone":"18600000098",}
{"username":"test0099","password":"pwd0099","email":"[email protected]","phone":"18600000099",}

Process finished with exit code 0

  

  到此,我们压测注册账号的测试数据已经准备完成,接下来就是压测脚本的编写。

  批量注册账号1(测试数据唯一性,不循环取数)

  场景:模拟多个用户并发注册,比如100个虚拟用户共享同一份测试数据,保证虚拟用户使用的数据不重复(唯一),并且数据取完,测试结束。

__author__ = 'Leo'

from locust import HttpLocust,task,TaskSet,between
import queue

class UserRegister(TaskSet):

    @task
    def test_register(self):
        # get_nowait() 取不到数据直接崩溃,直接跳到except; get() 取不到数据会一直等待
        try:
            # 从队列中取出数据
            data = eval(self.locust.user_data_queue.get_nowait())
            print("测试数据:%s"%data)
        # 使用get_nowait()方法,取不到数据,就进入这里
        except queue.Empty:
            print("测试数据已用完,结束!")
            exit(0)
        print('注册的用户账号: {}, 密码: {}' \
              .format(data['username'], data['password']))
        payload = {
            'username': data['username'],
            'password': data['password']

        }
        self.client.post('/register',data=payload)


class WebSiteUser(HttpLocust):
    host = 'https://www.testregister.com'
    task_set = UserRegister
    # 创建队列,先进先出
    user_data_queue = queue.Queue()
    # 循环加入队列
    for index in range(100):
        data = '''{
            "username": "test%04d",
            "password": "pwd%04d",
            "email": "test%[email protected]",
            "phone": "186%08d"
        }''' % (index, index, index, index)
        # 将data存入队列中
        user_data_queue.put_nowait(data.replace(' ', '').replace('\n', ''))
        # print(user_data_queue.get())

    wait_time = between(1,1)
if __name__ == '__main__':
    import os
    os.system('locust -f locust_register.py')

  运行结果:

[2020-06-27 11:01:32,723] WIN10-804191526/INFO/locust.main: Starting web monitor at http://*:8089
[2020-06-27 11:01:32,724] WIN10-804191526/INFO/locust.main: Starting Locust 0.14.6
[2020-06-27 11:01:36,216] WIN10-804191526/INFO/locust.runners: Hatching and swarming 1 users at the rate 1 users/s (0 users already running)...
[2020-06-27 11:01:36,216] WIN10-804191526/INFO/locust.runners: All locusts hatched: WebSiteUser: 1 (0 already running)
[2020-06-27 11:01:36,216] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0000', 'password': 'pwd0000', 'email': '[email protected]', 'phone': '18600000000'}
[2020-06-27 11:01:36,217] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:36,217] WIN10-804191526/INFO/stdout: 注册的用户账号: test0000, 密码: pwd0000
[2020-06-27 11:01:36,217] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:40,693] WIN10-804191526/INFO/locust.runners: Hatching and swarming 100 users at the rate 1 users/s (0 users already running)...
[2020-06-27 11:01:40,693] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0001', 'password': 'pwd0001', 'email': '[email protected]', 'phone': '18600000001'}
[2020-06-27 11:01:40,693] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:40,693] WIN10-804191526/INFO/stdout: 注册的用户账号: test0001, 密码: pwd0001
[2020-06-27 11:01:40,694] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:41,695] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0002', 'password': 'pwd0002', 'email': '[email protected]', 'phone': '18600000002'}
[2020-06-27 11:01:41,695] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:41,695] WIN10-804191526/INFO/stdout: 注册的用户账号: test0002, 密码: pwd0002
[2020-06-27 11:01:41,695] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:42,695] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0003', 'password': 'pwd0003', 'email': '[email protected]', 'phone': '18600000003'}
[2020-06-27 11:01:42,696] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:42,696] WIN10-804191526/INFO/stdout: 注册的用户账号: test0003, 密码: pwd0003
[2020-06-27 11:01:42,696] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:43,696] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0004', 'password': 'pwd0004', 'email': '[email protected]', 'phone': '18600000004'}
[2020-06-27 11:01:43,696] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:43,696] WIN10-804191526/INFO/stdout: 注册的用户账号: test0004, 密码: pwd0004
[2020-06-27 11:01:43,696] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:44,697] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0005', 'password': 'pwd0005', 'email': '[email protected]', 'phone': '18600000005'}
[2020-06-27 11:01:44,697] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:44,697] WIN10-804191526/INFO/stdout: 注册的用户账号: test0005, 密码: pwd0005
[2020-06-27 11:01:44,697] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:45,698] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0006', 'password': 'pwd0006', 'email': '[email protected]', 'phone': '18600000006'}
[2020-06-27 11:01:45,698] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:45,698] WIN10-804191526/INFO/stdout: 注册的用户账号: test0006, 密码: pwd0006
[2020-06-27 11:01:45,698] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:46,699] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0007', 'password': 'pwd0007', 'email': '[email protected]', 'phone': '18600000007'}
[2020-06-27 11:01:46,699] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:46,699] WIN10-804191526/INFO/stdout: 注册的用户账号: test0007, 密码: pwd0007
[2020-06-27 11:01:46,699] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:47,700] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0008', 'password': 'pwd0008', 'email': '[email protected]', 'phone': '18600000008'}
[2020-06-27 11:01:47,700] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:47,700] WIN10-804191526/INFO/stdout: 注册的用户账号: test0008, 密码: pwd0008
[2020-06-27 11:01:47,700] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:48,700] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0009', 'password': 'pwd0009', 'email': '[email protected]', 'phone': '18600000009'}
[2020-06-27 11:01:48,700] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:48,700] WIN10-804191526/INFO/stdout: 注册的用户账号: test0009, 密码: pwd0009
[2020-06-27 11:01:48,700] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:49,701] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0010', 'password': 'pwd0010', 'email': '[email protected]', 'phone': '18600000010'}
[2020-06-27 11:01:49,701] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:49,701] WIN10-804191526/INFO/stdout: 注册的用户账号: test0010, 密码: pwd0010
[2020-06-27 11:01:49,701] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:50,702] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0011', 'password': 'pwd0011', 'email': '[email protected]', 'phone': '18600000011'}
[2020-06-27 11:01:50,702] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:50,702] WIN10-804191526/INFO/stdout: 注册的用户账号: test0011, 密码: pwd0011
[2020-06-27 11:01:50,702] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:51,703] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0012', 'password': 'pwd0012', 'email': '[email protected]', 'phone': '18600000012'}
[2020-06-27 11:01:51,703] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:51,703] WIN10-804191526/INFO/stdout: 注册的用户账号: test0012, 密码: pwd0012
[2020-06-27 11:01:51,703] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:52,703] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0013', 'password': 'pwd0013', 'email': '[email protected]', 'phone': '18600000013'}
[2020-06-27 11:01:52,703] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:52,703] WIN10-804191526/INFO/stdout: 注册的用户账号: test0013, 密码: pwd0013
[2020-06-27 11:01:52,703] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:53,704] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0014', 'password': 'pwd0014', 'email': '[email protected]', 'phone': '18600000014'}
[2020-06-27 11:01:53,704] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:53,704] WIN10-804191526/INFO/stdout: 注册的用户账号: test0014, 密码: pwd0014
[2020-06-27 11:01:53,704] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:54,705] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0015', 'password': 'pwd0015', 'email': '[email protected]', 'phone': '18600000015'}
[2020-06-27 11:01:54,705] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:54,705] WIN10-804191526/INFO/stdout: 注册的用户账号: test0015, 密码: pwd0015
[2020-06-27 11:01:54,705] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:55,705] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0016', 'password': 'pwd0016', 'email': '[email protected]', 'phone': '18600000016'}
[2020-06-27 11:01:55,705] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:55,705] WIN10-804191526/INFO/stdout: 注册的用户账号: test0016, 密码: pwd0016
[2020-06-27 11:01:55,705] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:56,706] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0017', 'password': 'pwd0017', 'email': '[email protected]', 'phone': '18600000017'}
[2020-06-27 11:01:56,706] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:56,706] WIN10-804191526/INFO/stdout: 注册的用户账号: test0017, 密码: pwd0017
[2020-06-27 11:01:56,706] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:57,707] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0018', 'password': 'pwd0018', 'email': '[email protected]', 'phone': '18600000018'}
[2020-06-27 11:01:57,707] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:57,707] WIN10-804191526/INFO/stdout: 注册的用户账号: test0018, 密码: pwd0018
[2020-06-27 11:01:57,707] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:58,707] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0019', 'password': 'pwd0019', 'email': '[email protected]', 'phone': '18600000019'}
[2020-06-27 11:01:58,707] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:58,707] WIN10-804191526/INFO/stdout: 注册的用户账号: test0019, 密码: pwd0019
[2020-06-27 11:01:58,707] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:59,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0020', 'password': 'pwd0020', 'email': '[email protected]', 'phone': '18600000020'}
[2020-06-27 11:01:59,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:01:59,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0020, 密码: pwd0020
[2020-06-27 11:01:59,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:00,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0021', 'password': 'pwd0021', 'email': '[email protected]', 'phone': '18600000021'}
[2020-06-27 11:02:00,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:00,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0021, 密码: pwd0021
[2020-06-27 11:02:00,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:01,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0022', 'password': 'pwd0022', 'email': '[email protected]', 'phone': '18600000022'}
[2020-06-27 11:02:01,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:01,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0022, 密码: pwd0022
[2020-06-27 11:02:01,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:02,700] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0023', 'password': 'pwd0023', 'email': '[email protected]', 'phone': '18600000023'}
[2020-06-27 11:02:02,700] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:02,700] WIN10-804191526/INFO/stdout: 注册的用户账号: test0023, 密码: pwd0023
[2020-06-27 11:02:02,700] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:02,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0024', 'password': 'pwd0024', 'email': '[email protected]', 'phone': '18600000024'}
[2020-06-27 11:02:02,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:02,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0024, 密码: pwd0024
[2020-06-27 11:02:02,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:03,703] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0025', 'password': 'pwd0025', 'email': '[email protected]', 'phone': '18600000025'}
[2020-06-27 11:02:03,703] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:03,703] WIN10-804191526/INFO/stdout: 注册的用户账号: test0025, 密码: pwd0025
[2020-06-27 11:02:03,703] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:03,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0026', 'password': 'pwd0026', 'email': '[email protected]', 'phone': '18600000026'}
[2020-06-27 11:02:03,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:03,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0026, 密码: pwd0026
[2020-06-27 11:02:03,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:04,700] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0027', 'password': 'pwd0027', 'email': '[email protected]', 'phone': '18600000027'}
[2020-06-27 11:02:04,700] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:04,700] WIN10-804191526/INFO/stdout: 注册的用户账号: test0027, 密码: pwd0027
[2020-06-27 11:02:04,700] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:04,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0028', 'password': 'pwd0028', 'email': '[email protected]', 'phone': '18600000028'}
[2020-06-27 11:02:04,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:04,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0028, 密码: pwd0028
[2020-06-27 11:02:04,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:05,701] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0029', 'password': 'pwd0029', 'email': '[email protected]', 'phone': '18600000029'}
[2020-06-27 11:02:05,701] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:05,701] WIN10-804191526/INFO/stdout: 注册的用户账号: test0029, 密码: pwd0029
[2020-06-27 11:02:05,701] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:05,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0030', 'password': 'pwd0030', 'email': '[email protected]', 'phone': '18600000030'}
[2020-06-27 11:02:05,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:05,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0030, 密码: pwd0030
[2020-06-27 11:02:05,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:06,704] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0031', 'password': 'pwd0031', 'email': '[email protected]', 'phone': '18600000031'}
[2020-06-27 11:02:06,704] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:06,704] WIN10-804191526/INFO/stdout: 注册的用户账号: test0031, 密码: pwd0031
[2020-06-27 11:02:06,704] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:06,709] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0032', 'password': 'pwd0032', 'email': '[email protected]', 'phone': '18600000032'}
[2020-06-27 11:02:06,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:06,709] WIN10-804191526/INFO/stdout: 注册的用户账号: test0032, 密码: pwd0032
[2020-06-27 11:02:06,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:07,703] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0033', 'password': 'pwd0033', 'email': '[email protected]', 'phone': '18600000033'}
[2020-06-27 11:02:07,703] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:07,703] WIN10-804191526/INFO/stdout: 注册的用户账号: test0033, 密码: pwd0033
[2020-06-27 11:02:07,703] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:07,709] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0034', 'password': 'pwd0034', 'email': '[email protected]', 'phone': '18600000034'}
[2020-06-27 11:02:07,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:07,709] WIN10-804191526/INFO/stdout: 注册的用户账号: test0034, 密码: pwd0034
[2020-06-27 11:02:07,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:08,705] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0035', 'password': 'pwd0035', 'email': '[email protected]', 'phone': '18600000035'}
[2020-06-27 11:02:08,705] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:08,706] WIN10-804191526/INFO/stdout: 注册的用户账号: test0035, 密码: pwd0035
[2020-06-27 11:02:08,706] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:08,709] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0036', 'password': 'pwd0036', 'email': '[email protected]', 'phone': '18600000036'}
[2020-06-27 11:02:08,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:08,709] WIN10-804191526/INFO/stdout: 注册的用户账号: test0036, 密码: pwd0036
[2020-06-27 11:02:08,710] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:09,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0037', 'password': 'pwd0037', 'email': '[email protected]', 'phone': '18600000037'}
[2020-06-27 11:02:09,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:09,709] WIN10-804191526/INFO/stdout: 注册的用户账号: test0037, 密码: pwd0037
[2020-06-27 11:02:09,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:09,711] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0038', 'password': 'pwd0038', 'email': '[email protected]', 'phone': '18600000038'}
[2020-06-27 11:02:09,711] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:09,711] WIN10-804191526/INFO/stdout: 注册的用户账号: test0038, 密码: pwd0038
[2020-06-27 11:02:09,711] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:10,704] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0039', 'password': 'pwd0039', 'email': '[email protected]', 'phone': '18600000039'}
[2020-06-27 11:02:10,704] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:10,704] WIN10-804191526/INFO/stdout: 注册的用户账号: test0039, 密码: pwd0039
[2020-06-27 11:02:10,704] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:10,711] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0040', 'password': 'pwd0040', 'email': '[email protected]', 'phone': '18600000040'}
[2020-06-27 11:02:10,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:10,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0040, 密码: pwd0040
[2020-06-27 11:02:10,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:11,706] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0041', 'password': 'pwd0041', 'email': '[email protected]', 'phone': '18600000041'}
[2020-06-27 11:02:11,706] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:11,706] WIN10-804191526/INFO/stdout: 注册的用户账号: test0041, 密码: pwd0041
[2020-06-27 11:02:11,706] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:11,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0042', 'password': 'pwd0042', 'email': '[email protected]', 'phone': '18600000042'}
[2020-06-27 11:02:11,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:11,713] WIN10-804191526/INFO/stdout: 注册的用户账号: test0042, 密码: pwd0042
[2020-06-27 11:02:11,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:12,706] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0043', 'password': 'pwd0043', 'email': '[email protected]', 'phone': '18600000043'}
[2020-06-27 11:02:12,706] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:12,706] WIN10-804191526/INFO/stdout: 注册的用户账号: test0043, 密码: pwd0043
[2020-06-27 11:02:12,706] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:12,713] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0044', 'password': 'pwd0044', 'email': '[email protected]', 'phone': '18600000044'}
[2020-06-27 11:02:12,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:12,713] WIN10-804191526/INFO/stdout: 注册的用户账号: test0044, 密码: pwd0044
[2020-06-27 11:02:12,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:13,709] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0045', 'password': 'pwd0045', 'email': '[email protected]', 'phone': '18600000045'}
[2020-06-27 11:02:13,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:13,709] WIN10-804191526/INFO/stdout: 注册的用户账号: test0045, 密码: pwd0045
[2020-06-27 11:02:13,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:13,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0046', 'password': 'pwd0046', 'email': '[email protected]', 'phone': '18600000046'}
[2020-06-27 11:02:13,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:13,713] WIN10-804191526/INFO/stdout: 注册的用户账号: test0046, 密码: pwd0046
[2020-06-27 11:02:13,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:14,707] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0047', 'password': 'pwd0047', 'email': '[email protected]', 'phone': '18600000047'}
[2020-06-27 11:02:14,707] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:14,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0047, 密码: pwd0047
[2020-06-27 11:02:14,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:14,713] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0048', 'password': 'pwd0048', 'email': '[email protected]', 'phone': '18600000048'}
[2020-06-27 11:02:14,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:14,713] WIN10-804191526/INFO/stdout: 注册的用户账号: test0048, 密码: pwd0048
[2020-06-27 11:02:14,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:15,709] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0049', 'password': 'pwd0049', 'email': '[email protected]', 'phone': '18600000049'}
[2020-06-27 11:02:15,710] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:15,710] WIN10-804191526/INFO/stdout: 注册的用户账号: test0049, 密码: pwd0049
[2020-06-27 11:02:15,710] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:15,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0050', 'password': 'pwd0050', 'email': '[email protected]', 'phone': '18600000050'}
[2020-06-27 11:02:15,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:15,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0050, 密码: pwd0050
[2020-06-27 11:02:15,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:16,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0051', 'password': 'pwd0051', 'email': '[email protected]', 'phone': '18600000051'}
[2020-06-27 11:02:16,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:16,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0051, 密码: pwd0051
[2020-06-27 11:02:16,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:16,714] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0052', 'password': 'pwd0052', 'email': '[email protected]', 'phone': '18600000052'}
[2020-06-27 11:02:16,714] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:16,714] WIN10-804191526/INFO/stdout: 注册的用户账号: test0052, 密码: pwd0052
[2020-06-27 11:02:16,714] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:17,709] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0053', 'password': 'pwd0053', 'email': '[email protected]', 'phone': '18600000053'}
[2020-06-27 11:02:17,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:17,709] WIN10-804191526/INFO/stdout: 注册的用户账号: test0053, 密码: pwd0053
[2020-06-27 11:02:17,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:17,714] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0054', 'password': 'pwd0054', 'email': '[email protected]', 'phone': '18600000054'}
[2020-06-27 11:02:17,714] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:17,715] WIN10-804191526/INFO/stdout: 注册的用户账号: test0054, 密码: pwd0054
[2020-06-27 11:02:17,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:18,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0055', 'password': 'pwd0055', 'email': '[email protected]', 'phone': '18600000055'}
[2020-06-27 11:02:18,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:18,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0055, 密码: pwd0055
[2020-06-27 11:02:18,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:18,714] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0056', 'password': 'pwd0056', 'email': '[email protected]', 'phone': '18600000056'}
[2020-06-27 11:02:18,714] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:18,714] WIN10-804191526/INFO/stdout: 注册的用户账号: test0056, 密码: pwd0056
[2020-06-27 11:02:18,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:19,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0057', 'password': 'pwd0057', 'email': '[email protected]', 'phone': '18600000057'}
[2020-06-27 11:02:19,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:19,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0057, 密码: pwd0057
[2020-06-27 11:02:19,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:19,715] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0058', 'password': 'pwd0058', 'email': '[email protected]', 'phone': '18600000058'}
[2020-06-27 11:02:19,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:19,715] WIN10-804191526/INFO/stdout: 注册的用户账号: test0058, 密码: pwd0058
[2020-06-27 11:02:19,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:20,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0059', 'password': 'pwd0059', 'email': '[email protected]', 'phone': '18600000059'}
[2020-06-27 11:02:20,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:20,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0059, 密码: pwd0059
[2020-06-27 11:02:20,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:20,715] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0060', 'password': 'pwd0060', 'email': '[email protected]', 'phone': '18600000060'}
[2020-06-27 11:02:20,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:20,715] WIN10-804191526/INFO/stdout: 注册的用户账号: test0060, 密码: pwd0060
[2020-06-27 11:02:20,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:21,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0061', 'password': 'pwd0061', 'email': '[email protected]', 'phone': '18600000061'}
[2020-06-27 11:02:21,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:21,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0061, 密码: pwd0061
[2020-06-27 11:02:21,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:21,714] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0062', 'password': 'pwd0062', 'email': '[email protected]', 'phone': '18600000062'}
[2020-06-27 11:02:21,714] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:21,714] WIN10-804191526/INFO/stdout: 注册的用户账号: test0062, 密码: pwd0062
[2020-06-27 11:02:21,714] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:22,713] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0063', 'password': 'pwd0063', 'email': '[email protected]', 'phone': '18600000063'}
[2020-06-27 11:02:22,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:22,713] WIN10-804191526/INFO/stdout: 注册的用户账号: test0063, 密码: pwd0063
[2020-06-27 11:02:22,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:22,715] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0064', 'password': 'pwd0064', 'email': '[email protected]', 'phone': '18600000064'}
[2020-06-27 11:02:22,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:22,715] WIN10-804191526/INFO/stdout: 注册的用户账号: test0064, 密码: pwd0064
[2020-06-27 11:02:22,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:23,715] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0065', 'password': 'pwd0065', 'email': '[email protected]', 'phone': '18600000065'}
[2020-06-27 11:02:23,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:23,715] WIN10-804191526/INFO/stdout: 注册的用户账号: test0065, 密码: pwd0065
[2020-06-27 11:02:23,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:23,719] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0066', 'password': 'pwd0066', 'email': '[email protected]', 'phone': '18600000066'}
[2020-06-27 11:02:23,719] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:23,719] WIN10-804191526/INFO/stdout: 注册的用户账号: test0066, 密码: pwd0066
[2020-06-27 11:02:23,719] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:24,705] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0067', 'password': 'pwd0067', 'email': '[email protected]', 'phone': '18600000067'}
[2020-06-27 11:02:24,705] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:24,705] WIN10-804191526/INFO/stdout: 注册的用户账号: test0067, 密码: pwd0067
[2020-06-27 11:02:24,705] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:24,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0068', 'password': 'pwd0068', 'email': '[email protected]', 'phone': '18600000068'}
[2020-06-27 11:02:24,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:24,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0068, 密码: pwd0068
[2020-06-27 11:02:24,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:24,715] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0069', 'password': 'pwd0069', 'email': '[email protected]', 'phone': '18600000069'}
[2020-06-27 11:02:24,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:24,715] WIN10-804191526/INFO/stdout: 注册的用户账号: test0069, 密码: pwd0069
[2020-06-27 11:02:24,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:25,709] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0070', 'password': 'pwd0070', 'email': '[email protected]', 'phone': '18600000070'}
[2020-06-27 11:02:25,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:25,709] WIN10-804191526/INFO/stdout: 注册的用户账号: test0070, 密码: pwd0070
[2020-06-27 11:02:25,709] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:25,715] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0071', 'password': 'pwd0071', 'email': '[email protected]', 'phone': '18600000071'}
[2020-06-27 11:02:25,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:25,716] WIN10-804191526/INFO/stdout: 注册的用户账号: test0071, 密码: pwd0071
[2020-06-27 11:02:25,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:25,717] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0072', 'password': 'pwd0072', 'email': '[email protected]', 'phone': '18600000072'}
[2020-06-27 11:02:25,717] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:25,717] WIN10-804191526/INFO/stdout: 注册的用户账号: test0072, 密码: pwd0072
[2020-06-27 11:02:25,717] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:26,704] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0073', 'password': 'pwd0073', 'email': '[email protected]', 'phone': '18600000073'}
[2020-06-27 11:02:26,704] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:26,704] WIN10-804191526/INFO/stdout: 注册的用户账号: test0073, 密码: pwd0073
[2020-06-27 11:02:26,704] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:26,713] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0074', 'password': 'pwd0074', 'email': '[email protected]', 'phone': '18600000074'}
[2020-06-27 11:02:26,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:26,713] WIN10-804191526/INFO/stdout: 注册的用户账号: test0074, 密码: pwd0074
[2020-06-27 11:02:26,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:26,716] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0075', 'password': 'pwd0075', 'email': '[email protected]', 'phone': '18600000075'}
[2020-06-27 11:02:26,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:26,716] WIN10-804191526/INFO/stdout: 注册的用户账号: test0075, 密码: pwd0075
[2020-06-27 11:02:26,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:27,707] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0076', 'password': 'pwd0076', 'email': '[email protected]', 'phone': '18600000076'}
[2020-06-27 11:02:27,707] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:27,707] WIN10-804191526/INFO/stdout: 注册的用户账号: test0076, 密码: pwd0076
[2020-06-27 11:02:27,707] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:27,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0077', 'password': 'pwd0077', 'email': '[email protected]', 'phone': '18600000077'}
[2020-06-27 11:02:27,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:27,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0077, 密码: pwd0077
[2020-06-27 11:02:27,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:27,716] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0078', 'password': 'pwd0078', 'email': '[email protected]', 'phone': '18600000078'}
[2020-06-27 11:02:27,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:27,716] WIN10-804191526/INFO/stdout: 注册的用户账号: test0078, 密码: pwd0078
[2020-06-27 11:02:27,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:28,709] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0079', 'password': 'pwd0079', 'email': '[email protected]', 'phone': '18600000079'}
[2020-06-27 11:02:28,710] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:28,710] WIN10-804191526/INFO/stdout: 注册的用户账号: test0079, 密码: pwd0079
[2020-06-27 11:02:28,710] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:28,715] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0080', 'password': 'pwd0080', 'email': '[email protected]', 'phone': '18600000080'}
[2020-06-27 11:02:28,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:28,715] WIN10-804191526/INFO/stdout: 注册的用户账号: test0080, 密码: pwd0080
[2020-06-27 11:02:28,715] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:28,716] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0081', 'password': 'pwd0081', 'email': '[email protected]', 'phone': '18600000081'}
[2020-06-27 11:02:28,717] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:28,717] WIN10-804191526/INFO/stdout: 注册的用户账号: test0081, 密码: pwd0081
[2020-06-27 11:02:28,717] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:29,708] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0082', 'password': 'pwd0082', 'email': '[email protected]', 'phone': '18600000082'}
[2020-06-27 11:02:29,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:29,708] WIN10-804191526/INFO/stdout: 注册的用户账号: test0082, 密码: pwd0082
[2020-06-27 11:02:29,708] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:29,713] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0083', 'password': 'pwd0083', 'email': '[email protected]', 'phone': '18600000083'}
[2020-06-27 11:02:29,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:29,713] WIN10-804191526/INFO/stdout: 注册的用户账号: test0083, 密码: pwd0083
[2020-06-27 11:02:29,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:29,717] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0084', 'password': 'pwd0084', 'email': '[email protected]', 'phone': '18600000084'}
[2020-06-27 11:02:29,718] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:29,718] WIN10-804191526/INFO/stdout: 注册的用户账号: test0084, 密码: pwd0084
[2020-06-27 11:02:29,718] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:30,713] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0085', 'password': 'pwd0085', 'email': '[email protected]', 'phone': '18600000085'}
[2020-06-27 11:02:30,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:30,713] WIN10-804191526/INFO/stdout: 注册的用户账号: test0085, 密码: pwd0085
[2020-06-27 11:02:30,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:30,715] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0086', 'password': 'pwd0086', 'email': '[email protected]', 'phone': '18600000086'}
[2020-06-27 11:02:30,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:30,716] WIN10-804191526/INFO/stdout: 注册的用户账号: test0086, 密码: pwd0086
[2020-06-27 11:02:30,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:30,718] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0087', 'password': 'pwd0087', 'email': '[email protected]', 'phone': '18600000087'}
[2020-06-27 11:02:30,718] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:30,719] WIN10-804191526/INFO/stdout: 注册的用户账号: test0087, 密码: pwd0087
[2020-06-27 11:02:30,719] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:31,717] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0088', 'password': 'pwd0088', 'email': '[email protected]', 'phone': '18600000088'}
[2020-06-27 11:02:31,717] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:31,717] WIN10-804191526/INFO/stdout: 注册的用户账号: test0088, 密码: pwd0088
[2020-06-27 11:02:31,717] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:31,719] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0089', 'password': 'pwd0089', 'email': '[email protected]', 'phone': '18600000089'}
[2020-06-27 11:02:31,719] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:31,719] WIN10-804191526/INFO/stdout: 注册的用户账号: test0089, 密码: pwd0089
[2020-06-27 11:02:31,719] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:31,721] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0090', 'password': 'pwd0090', 'email': '[email protected]', 'phone': '18600000090'}
[2020-06-27 11:02:31,721] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:31,721] WIN10-804191526/INFO/stdout: 注册的用户账号: test0090, 密码: pwd0090
[2020-06-27 11:02:31,721] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:32,710] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0091', 'password': 'pwd0091', 'email': '[email protected]', 'phone': '18600000091'}
[2020-06-27 11:02:32,710] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:32,710] WIN10-804191526/INFO/stdout: 注册的用户账号: test0091, 密码: pwd0091
[2020-06-27 11:02:32,711] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:32,716] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0092', 'password': 'pwd0092', 'email': '[email protected]', 'phone': '18600000092'}
[2020-06-27 11:02:32,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:32,716] WIN10-804191526/INFO/stdout: 注册的用户账号: test0092, 密码: pwd0092
[2020-06-27 11:02:32,716] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:32,719] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0093', 'password': 'pwd0093', 'email': '[email protected]', 'phone': '18600000093'}
[2020-06-27 11:02:32,719] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:32,719] WIN10-804191526/INFO/stdout: 注册的用户账号: test0093, 密码: pwd0093
[2020-06-27 11:02:32,720] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:33,710] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0094', 'password': 'pwd0094', 'email': '[email protected]', 'phone': '18600000094'}
[2020-06-27 11:02:33,710] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:33,710] WIN10-804191526/INFO/stdout: 注册的用户账号: test0094, 密码: pwd0094
[2020-06-27 11:02:33,710] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:33,718] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0095', 'password': 'pwd0095', 'email': '[email protected]', 'phone': '18600000095'}
[2020-06-27 11:02:33,718] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:33,719] WIN10-804191526/INFO/stdout: 注册的用户账号: test0095, 密码: pwd0095
[2020-06-27 11:02:33,719] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:33,720] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0096', 'password': 'pwd0096', 'email': '[email protected]', 'phone': '18600000096'}
[2020-06-27 11:02:33,720] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:33,720] WIN10-804191526/INFO/stdout: 注册的用户账号: test0096, 密码: pwd0096
[2020-06-27 11:02:33,720] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:34,712] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0097', 'password': 'pwd0097', 'email': '[email protected]', 'phone': '18600000097'}
[2020-06-27 11:02:34,712] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:34,712] WIN10-804191526/INFO/stdout: 注册的用户账号: test0097, 密码: pwd0097
[2020-06-27 11:02:34,713] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:34,718] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0098', 'password': 'pwd0098', 'email': '[email protected]', 'phone': '18600000098'}
[2020-06-27 11:02:34,718] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:34,718] WIN10-804191526/INFO/stdout: 注册的用户账号: test0098, 密码: pwd0098
[2020-06-27 11:02:34,718] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:34,720] WIN10-804191526/INFO/stdout: 测试数据:{'username': 'test0099', 'password': 'pwd0099', 'email': '[email protected]', 'phone': '18600000099'}
[2020-06-27 11:02:34,720] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:34,720] WIN10-804191526/INFO/stdout: 注册的用户账号: test0099, 密码: pwd0099
[2020-06-27 11:02:34,720] WIN10-804191526/INFO/stdout: 
[2020-06-27 11:02:35,715] WIN10-804191526/INFO/stdout: 测试数据已用完,结束!
[2020-06-27 11:02:35,715] WIN10-804191526/INFO/stdout: 

Process finished with exit code 0

  界面:

  修改脚本:

  

  使用get()方法从队列取数,得到的结果:

  批量注册账号2(测试数据唯一性,循环取数)

   场景:模拟多个用户并发注册,比如100个虚拟用户共享同一份测试数据,保证虚拟用户使用的数据不重复(唯一),并且数据取完,可以重复使用。

  

   该种场景的实现方式与上一种场景基本相同,唯一的差异在于,每次使用完数据后,需要再将数据放入队列中。

__author__ = 'Leo'

from locust import HttpLocust,task,TaskSet,between
import queue

class UserRegister(TaskSet):

    @task
    def test_register(self):
        # get_nowait() 取不到数据直接崩溃,直接跳到except; get() 取不到数据会一直等待
        try:
            # 从队列中取出数据
            data = eval(self.locust.user_data_queue.get())
            print("测试数据:%s"%data)
        # 使用get_nowait()方法,取不到数据,就进入这里
        except queue.Empty:
            print("测试数据已用完,结束!")
            exit(0)
        print('注册的用户账号: {}, 密码: {}' \
              .format(data['username'], data['password']))
        payload = {
            'username': data['username'],
            'password': data['password']

        }
        self.client.post('/register',data=payload)
        self.locust.user_data_queue.put_nowait(str(data))


class WebSiteUser(HttpLocust):
    host = 'https://www.baidu.com'
    task_set = UserRegister
    # 创建队列,先进先出
    user_data_queue = queue.Queue()
    # 循环加入队列
    for index in range(100):
        data = '''{
            "username": "test%04d",
            "password": "pwd%04d",
            "email": "test%[email protected]",
            "phone": "186%08d"
        }''' % (index, index, index, index)
        # 将data存入队列中
        user_data_queue.put_nowait(data.replace(' ', '').replace('\n', ''))
        # print(user_data_queue.get())

    wait_time = between(1,3)
if __name__ == '__main__':
    import os
    os.system('locust -f locust_register.py')

  结果:

   因为循环取数,所以脚本不会停下来,为了演示,截图看看界面,此界面没有跑完:

  这种模式就是测试数据循环使用,但并不同时使用。

  批量注册账号3(测试数据重复使用,循环取数)

  所有并发虚拟用户共享同一份测试数据,各虚拟用户在数据列表中循环取值。

  例如,模拟3用户并发请求网页,总共有100个URL地址,每个虚拟用户都会依次循环加载这100个URL地址;加载示例如下表所示。

   

   下面我设置的场景是,2个用户并发请求5个URL,每个虚拟用户都会依次请求这5个URL,demo如下:

__author__ = 'Leo'
from locust import TaskSet, task, HttpLocust,between

class UserBehavior(TaskSet):
    def on_start(self):
        self.index = 0


    @task
    def test_visit(self):
        url = self.locust.share_data[self.index]
        print('visit url: %s' % url)
        self.index = (self.index + 1) % len(self.locust.share_data)  # 一个数除以另一个数,要是比另一个数小,商数就是0,余数就是它自己。
        self.client.get('/register')

class WebsiteUser(HttpLocust):
    host = 'https://www.baidu.com'
    task_set = UserBehavior
    share_data = ['url1', 'url2', 'url3', 'url4', 'url5']
    wait_time = between(1,3)
    
if __name__ == '__main__':
    import os
    os.system('locust -f locust_batch_data.py')

  结果:

[2020-06-27 17:50:10,104] WIN10-804191526/INFO/locust.main: Starting web monitor at http://*:8089
[2020-06-27 17:50:10,104] WIN10-804191526/INFO/locust.main: Starting Locust 0.14.6
[2020-06-27 17:50:13,768] WIN10-804191526/INFO/locust.runners: Hatching and swarming 2 users at the rate 1 users/s (0 users already running)...
[2020-06-27 17:50:13,768] WIN10-804191526/INFO/stdout: visit url: url1
[2020-06-27 17:50:13,768] WIN10-804191526/INFO/stdout: 
[2020-06-27 17:50:14,769] WIN10-804191526/INFO/locust.runners: All locusts hatched: WebsiteUser: 2 (0 already running)
[2020-06-27 17:50:14,769] WIN10-804191526/INFO/stdout: visit url: url1
[2020-06-27 17:50:14,769] WIN10-804191526/INFO/stdout: 
[2020-06-27 17:50:16,161] WIN10-804191526/INFO/stdout: visit url: url2
[2020-06-27 17:50:16,161] WIN10-804191526/INFO/stdout: 
[2020-06-27 17:50:16,749] WIN10-804191526/INFO/stdout: visit url: url2
[2020-06-27 17:50:16,749] WIN10-804191526/INFO/stdout: 
[2020-06-27 17:50:17,547] WIN10-804191526/INFO/stdout: visit url: url3
[2020-06-27 17:50:17,547] WIN10-804191526/INFO/stdout: 
[2020-06-27 17:50:18,619] WIN10-804191526/INFO/stdout: visit url: url3
[2020-06-27 17:50:18,619] WIN10-804191526/INFO/stdout: 
[2020-06-27 17:50:19,187] WIN10-804191526/INFO/stdout: visit url: url4
[2020-06-27 17:50:19,187] WIN10-804191526/INFO/stdout: 
[2020-06-27 17:50:20,854] WIN10-804191526/INFO/stdout: visit url: url5
[2020-06-27 17:50:20,854] WIN10-804191526/INFO/stdout: 
[2020-06-27 17:50:21,425] WIN10-804191526/INFO/stdout: visit url: url4

  总结

  自此,Locust参数化介绍完,有兴趣的可以深入学习一下。如果有对测试、测试开发、性能测试等领域感兴趣的,有独到见解的可以加入QQ群,一起学习和进步。

猜你喜欢

转载自www.cnblogs.com/liudinglong/p/13197017.html
今日推荐