我已经使用xlrd从列中提取数据(下面的数据)。我需要把ip地址分组。因此,在输出中显示在一起的ip地址属于同一个池,而单个ip地址则位于各自的池中。例如(10.100.33.183,10.100.33.184)属于(pool1)。(池6=10.100.33.89)
我该如何实现这一切。你知道吗
['', '', '', '', '', '', '', 'Pool Member IP', '', '10.100.33.184 (S56723FR6VL01)', '10.100.33.183 (S56723FR6VL02)', '', '', '', '', '', '', '', '10.101.33.182 (S56723FR6VL03)', '10.100.33.181 (S56723FR6VL04)', '', '', '', '', '', '', '', '10.100.33.180 (S56723FR6VL05)', '10.100.33.179 (S56723FR6VL06)', '', '', '', '', '', '', '', '10.100.33.178 (S56723FR6VL07)', '10.100.33.177 (S56723FR6VL08)', '', '', '', '', '', '', '', '10.100.33.90 (S56723FR6VL09)', '', '', '', '', '', '', '', '', '10.100.33.89 (S56723FR6VL0A)', '', '', '', '', '', '', '', '', '10.100.33.91 (S56723FR6VW01)', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
编辑:修正了句子
@franciscosolima的解决方案很好。正则表达式还有另一种方法。你知道吗
只需将连续的匹配项添加到同一个池中即可。否则,请初始化一个新的。regex模式将从一开始就匹配,您可以将其配置为检测IPv6地址。你知道吗
打印输出:
相关问题 更多 >
编程相关推荐