添加策略验证关键字
This commit is contained in:
@@ -180,7 +180,50 @@ class Order:
|
||||
Order.UpdateAllvalues(self,chdict, key, value)
|
||||
element[k] = chdict
|
||||
|
||||
#递归提取json中符合要求键的值
|
||||
import json
|
||||
|
||||
def get_dict_allkeys(self,dict_a):
|
||||
"""
|
||||
遍历嵌套字典,获取json返回结果的所有key值
|
||||
:param dict_a:
|
||||
:return: key_list
|
||||
"""
|
||||
if isinstance(dict_a, dict): # 使用isinstance检测数据类型
|
||||
# 如果为字典类型,则提取key存放到key_list中
|
||||
for x in range(len(dict_a)):
|
||||
temp_key = list(dict_a.keys())[x]
|
||||
temp_value = dict_a[temp_key]
|
||||
if temp_key.endswith("Id"):
|
||||
key_list.append(temp_value)
|
||||
Order.get_dict_allkeys(self,temp_value) # 自我调用实现无限遍历
|
||||
elif isinstance(dict_a, list):
|
||||
# 如果为列表类型,则遍历列表里的元素,将字典类型的按照上面的方法提取key
|
||||
for k in dict_a:
|
||||
if isinstance(k, dict):
|
||||
for x in range(len(k)):
|
||||
temp_key = list(k.keys())[x]
|
||||
temp_value = k[temp_key]
|
||||
if temp_key.endswith("Id"):
|
||||
key_list.append(temp_value)
|
||||
Order.get_dict_allkeys(self,temp_value) # 自我调用实现无限遍历
|
||||
return key_list
|
||||
|
||||
# 判断值是否在列表中
|
||||
def VerifyProxy(self,data,lists):
|
||||
global key_list
|
||||
key_list = []
|
||||
datas = Order.get_dict_allkeys(self,data)
|
||||
print(type(datas))
|
||||
lists=lists.split(",")
|
||||
print(type(lists))
|
||||
print(datas)
|
||||
print(lists)
|
||||
|
||||
if set(datas) > set(lists):
|
||||
return "ture"
|
||||
else:
|
||||
return "flase"
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user