Python 实现递归
import requests
def find_children(data, elements):
children_found = []
for items in data[elements]:
children_found.append(items['name'])
if items['children']:
more_children = find_children(items, elements)
for item in more_children:
children_found.append(item)
return children_found
headers = {'Content-type': 'application/json', xxxxx}
url = "https://xxxxx"
response = requests.get(url=url,headers=headers).json()
node_f = response["data"]["x x x"]["node"]
a = find_children(node_f, 'children')
print(a)
来源:https://www.jianshu.com/p/e8fcff19b3d6

浙公网安备 33010602011771号