关于python数据处理的问题
host_msg = [
{'ipv4': ['10.0.0.1'], '10.0.0.1': [{'switch': '00:00:00:00:00:00:00:01', 'port': '4'}]},
{'ipv4': ['10.0.0.3'], '10.0.0.3': [{'switch': '00:00:00:00:00:00:00:0a', 'port': '4'}]},
{'ipv4': ['10.0.0.2'], '10.0.0.2': [{'switch': '00:00:00:00:00:00:00:0b', 'port': '4'}]}
]
我希望host_msg按照ipv4的大小进行排序,变成下面这中输出
host_msg = [
{'ipv4': ['10.0.0.1'], '10.0.0.1': [{'switch': '00:00:00:00:00:00:00:01', 'port': '4'}]},
{'ipv4': ['10.0.0.3'], '10.0.0.3': [{'switch': '00:00:00:00:00:00:00:0a', 'port': '4'}]},
{'ipv4': ['10.0.0.2'], '10.0.0.2': [{'switch': '00:00:00:00:00:00:00:0b', 'port': '4'}]}
]
请问各位应该怎么做?
推荐文章: