我正在尝试搜索列表中的任何IP。 下面是字符串列表,从这个列表我想搜索是否存在任何使用python的IP。
[
'Neighbour',
'Information:',
'Chassis',
'type',
':',
'Mac',
'address',
'address'
' :'
'146.89.4.32'
]
答案 0 :(得分:1)
使用正则表达式。
Please check this link for more info on regex !!!
More info how below regex works !!!
import re
val = ['Neighbour', 'Information:', 'Chassis', 'type', ':', 'Mac', 'address', 'Address', ':', '146.89.4.32']
for v in val:
temp = re.findall(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',v)
if len(temp) !=0:
print v