如何使用 python 搜索列表中的任意数字出口
how to search any number exits in a list using python
我正在尝试搜索列表中的任何 IP。
下面是字符串列表,我想从这个列表中使用 python 搜索是否存在任何 IP。
[
'Neighbour',
'Information:',
'Chassis',
'type',
':',
'Mac',
'address',
'address'
' :'
'146.89.4.32'
]
使用正则表达式。
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
我正在尝试搜索列表中的任何 IP。 下面是字符串列表,我想从这个列表中使用 python 搜索是否存在任何 IP。
[
'Neighbour',
'Information:',
'Chassis',
'type',
':',
'Mac',
'address',
'address'
' :'
'146.89.4.32'
]
使用正则表达式。
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