需要学习资源,请点击开挂教学楼 <https://www.xpcoding.com/>
I am new to python and I've tried to search but can seem to find a sample of 
what I am trying to accomplish. Any ideas are much appreciated. I am working 
with a nested dictionary with lots of key and values but I only want to print 
specific ones using a filtered list variable.
my_nested_dict = {"global": {"peers": {"15.1.1.1": {"remote_id": "15.1.1.1", 
"address_family": {"ipv4": {"sent_prefixes": 1, "received_prefixes": 4, 
"accepted_prefixes": 4}}, "remote_as": 65002, "uptime": 13002, "is_enabled": 
true, "is_up": true, "description": "== R3 BGP Neighbor ==", "local_as": 
65002}}, "router_id": "15.1.1.2"}} 
I would like to a filter through it and choose which keys and values to print 
out
filtered_list = ['peers', 'remote_id', 'remote_as', 'uptime'] 
and achieve a out out of
peers: 15.1.1.1 remote_id: 15.1.1.1 remote_as: 65002 uptime: 13002 
 
热门工具 换一换
