1 Star 0 Fork 0

朱烜宇/FileDeal

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
write.py 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
hello_python 提交于 2019-05-21 17:39 +08:00 . test ok
# 用于模拟生成master文件和detail文件脚本
import time
import json
import datetime
import uuid
import shutil
master_path = "/Users/zhuxuanyu/python_xuexi/FileService/test/master/"
detail_path = "/Users/zhuxuanyu/python_xuexi/FileService/test/detail/"
start = time.time()
for i in range(100):
master_file_name = str(uuid.uuid1())
msg_uuid = str(uuid.uuid1())
firstid = str(uuid.uuid1())
secondid = str(uuid.uuid1())
now_time = datetime.datetime.now()
n_time = now_time.strftime('%Y-%m-%d %H:%M:%S')
n_date = now_time.strftime('%Y-%m-%d')
master_data = {
"msg_uuid": msg_uuid,
"server":"my_server",
"firstid": firstid,
"secondid": secondid,
"msg_data": "hello world"
}
with open(master_path + master_file_name + '.master', 'w') as f:
f.write(json.dumps(master_data))
start_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
end_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
cdr_first_data = {
"msg_uuid": msg_uuid,
"mem_id": firstid,
"stime": start_time,
"etime": end_time,
}
with open(detail_path + firstid + ".json", "w") as f:
f.write(json.dumps(cdr_first_data))
cdr_second_data = {
"msg_uuid": msg_uuid,
"mem_id": secondid,
"stime": start_time,
"etime": end_time,
}
with open(detail_path + secondid + ".json","w") as f:
f.write(json.dumps(cdr_second_data))
time.sleep(0.002)
end = time.time()
print('now is %s' % datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))
print("total time %s" % (end - start))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/pythonista/FileDeal.git
git@gitee.com:pythonista/FileDeal.git
pythonista
FileDeal
FileDeal
master

搜索帮助