1 Star 0 Fork 1

tushenmei/api_test

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
demo.py 3.22 KB
一键复制 编辑 原始数据 按行查看 历史
tushenmei 提交于 2022-05-11 18:42 . aa
# import re
#
# import jsonpath
# import yaml
#
# return_json = {'folders': [
# {'folder_id': 'folder.qunxUVQKjZE99_KsvlH1LA', 'folder_name': 'helloworld', 'is_creator': True,
# 'created_at': '2022-04-28T12:19:17.350876904Z', 'last_edit_at': '2022-04-28T13:33:03.782216276Z',
# 'favorite': False}, {'folder_id': 'folder.sVY98zAn5xk3xiNFxI4b0K', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:07:39.527428092Z',
# 'last_edit_at': '2022-04-28T13:07:39.527428092Z', 'favorite': False},
# {'folder_id': 'folder.U7kwOvZhTjPjOpe7-u5VyL', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:10:15.463068441Z', 'last_edit_at': '2022-04-28T13:10:15.463068441Z',
# 'favorite': False}, {'folder_id': 'folder.wLg5tLlVc5bDOUPZoM9lna', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:16:42.72617247Z',
# 'last_edit_at': '2022-04-28T13:16:42.72617247Z', 'favorite': False},
# {'folder_id': 'folder.OmupKjc5xQbVk-C-Cor0_9', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:19:34.218893237Z', 'last_edit_at': '2022-04-28T13:19:34.218893237Z',
# 'favorite': False}, {'folder_id': 'folder.yjOw7oHNr_ZTxGYoD65N9l', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:33:03.090030529Z',
# 'last_edit_at': '2022-04-28T13:33:03.090030529Z', 'favorite': False},
# {'folder_id': 'folder.F4ffinZuds4ohlunEorYD2', 'folder_name': 'hello', 'is_creator': True,
# 'created_at': '2022-04-28T13:39:06.031684501Z', 'last_edit_at': '2022-04-28T13:39:06.031684501Z',
# 'favorite': False}]}
#
# with open(r"C:\Users\Fly\Desktop\api_test\extract.yaml", encoding='utf-8') as f:
# value = yaml.load(f, Loader=yaml.FullLoader)
# print(value["folder_id_list"])
#
#
# import json
# # aa = str({"folder_ids": ['folder.wLg5tLlVc5bDOUPZoM9lna', 'folder.t-wPVvvsCcGe4JAbIfyThR', 'folder.L4aju2Agfu-5VPIySgIePF', 'folder.KZTyFcMlr_qBGsRmOANWwD', 'folder{"folder_ids": ['folder.wLg5tLlVc5bDOUPZoM9lna', 'folder.t-wPVvvsCcGe4JAbIfyThR', 'folder.L4aju2Agfu-5VPIySgIePF', 'folder.KZTyFcMlr_qBGsRmOANWwD', 'folder.QMzE8i8o1IG21n1ZYBCFpy', 'folder.2v__f_U0G4EPGuOSl3Kv6Q']}"
# aa = str({'folder_ids': ['folder.wLg5tLlVc5bDOUPZoM9lna', 'folder.t-wPVvvsCcGe4JAbIfyThR', 'folder.L4aju2Agfu-5VPIySgIePF', 'folder.KZTyFcMlr_qBGsRmOANWwD', 'folder.QMzE8i8o1IG21n1ZYBCFpy', 'folder.2v__f_U0G4EPGuOSl3Kv6Q']})
# res = json.loads(aa)
# print(res)
import yaml
def write_extract_yaml(data):
"""
Write key-value pairs to extract.yaml
:param data: like {key:value}
:return: None
"""
flag = False
with open(r"C:\Users\Fly\Desktop\api_test\extract.yaml", encoding='utf-8') as f:
value = yaml.load(f, Loader=yaml.FullLoader)
for item in list(data.keys()):
if item in value.keys():
flag = True
break
if not flag:
with open(r"C:\Users\Fly\Desktop\api_test\extract.yaml", encoding='utf-8', mode="a") as f:
yaml.dump(data=data, stream=f, allow_unicode=True)
write_extract_yaml({"comment_id": "234455"})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/tushenmei/api_test.git
[email protected]:tushenmei/api_test.git
tushenmei
api_test
api_test
master

搜索帮助