import sys
import datetime
import random
import string
import time
target = open("testdata.txt", 'a')
#指定需要产生多少条json数据
for i in range(100):
now = datetime.datetime.now()
now_time = now.strftime('%Y-%m-%d %H:%M:%S')
today = now.strftime('%Y-%m-%d')
add_time = ''.join(random.sample(string.digits, 10))
data="{"log_ds": "" + today + ""," + ""log_id": "addfriend", "log_ts": "" + now_time + ""," + ""region": 1, "server": "6", "add_time": " + add_time + "," + ""host_pid": "1419395816029523974", "friend_pid": "1210342673502494726", "friend_count": 1, "adddouble.test": 1.25}"
print(data)
target.writelines(str(data) + '
')
time.sleep(0.01)
target.close()