UI工程师锻造系列视频教程

论坛 期权论坛 脚本     
匿名网站用户   2020-12-19 12:57   726   0

需要学习资源,请点击开挂教学楼

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
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1136255
帖子:227251
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP