56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
import json
|
||
def get_dict_allkeys(dict_a):
|
||
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)
|
||
get_dict_allkeys(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)
|
||
get_dict_allkeys(temp_value) # 自我调用实现无限遍历
|
||
return key_list
|
||
def VerifyProxy(data,lists):
|
||
global key_list
|
||
key_list = []
|
||
datas = get_dict_allkeys(data)
|
||
print(type(datas))
|
||
lists=lists.split(",")
|
||
print(type(lists))
|
||
print("gsd")
|
||
datas2=list(map(str,datas))
|
||
print(datas2)
|
||
print(datas)
|
||
print(lists)
|
||
|
||
if set(datas2) > set(lists):
|
||
return "true"
|
||
else:
|
||
return "flase"
|
||
# 判断值是否在列表中
|
||
# 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("gsd")
|
||
# datas2=list(map(str,datas))
|
||
# print(datas2)
|
||
# print(datas)
|
||
# print(lists)
|
||
|
||
# if set(datas2) > set(lists):
|
||
# return "true"
|
||
# else:
|
||
# return "flase" |