import random
data = {"name": "tom", "age": 18}
# 复制100次
copies = [data.copy() for _ in range(11)]
aa='dddddddddd'
# 随机生成name和age
a= '{"index":{"_index":"dumpindex"}}'
for item in copies:
item["name"] = ''.join(random.choice('abcdefghijklmnopqrstuvwxyz') for _ in range(4))
item["age"] = random.randint(18, 30)
print( str(copies))
# print(a+'\n'+copies)
[{'name': 'pdbe', 'age': 18}, {'name': 'shyy', 'age': 23}, {'name': 'vtmi', 'age': 21}, {'name': 'atok', 'age': 27}, {'name': 'wuvt', 'age': 22}, {'name': 'pafm', 'age': 29}, {'name': 'lrlp', 'age': 21}, {'name': 'dhvf', 'age': 30}, {'name': 'qvzr', 'age': 19}, {'name': 'vhfd', 'age': 29}, {'name': 'kamw', 'age': 19}]
进程已结束,退出代码为 0
{"index":{"_index":"dumpindex"}}
{"name": "qrqp", "age": 28}
{"index":{"_index":"dumpindex"}}
{"name": "frxh", "age": 22}