python3 正则表达式在文本搜索应用实例

题目描述:

在此文本中把标红的端口号 地址 进行匹配出来。要求当我输入端口号 输出地址

例如 端口号:BVI1  得到地址: 10f3.116c.e6a7, 192.168.100.254/24 

*******************代码在最后面************************************************

*******************代码在最后面************************************************

RP/0/RSP0/CPU0:2_c-leaf-1#  show interfaces

Thu Sep  7 15:17:18.514 UTC


BVI1 is down, line protocol is down
  Interface state transitions: 0
  Hardware is Bridge-Group Virtual Interface, address is 10f3.116c.e6a7
  Internet address is 192.168.100.254/24
  MTU 1514 bytes, BW 10000000 Kbit (Max: 10000000 Kbit)
     reliability 255/255, txload 0/255, rxload 0/255
  Encapsulation ARPA,  loopback not set,
  ARP type ARPA, ARP timeout 04:00:00
  Last input never, output never
  Last clearing of "show interface" counters never
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     0 packets input, 0 bytes, 0 total input drops
     0 drops for unrecognized upper-level protocol
     Received 0 broadcast packets, 0 multicast packets
     0 packets output, 0 bytes, 0 total output drops
     Output 0 broadcast packets, 0 multicast packets


BVI100 is down, line protocol is down
  Interface state transitions: 6
  Hardware is Bridge-Group Virtual Interface, address is 10f3.116c.e6a7
  Internet address is 192.168.1.100/24
  MTU 1514 bytes, BW 10000000 Kbit (Max: 10000000 Kbit)
     reliability 255/255, txload 0/255, rxload 0/255
  Encapsulation ARPA,  loopback not set,
  Last link flapped 3w1d
  ARP type ARPA, ARP timeout 04:00:00
  Last input 3w1d, output 3w1d
  Last clearing of "show interface" counters never
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     3196 packets input, 151340 bytes, 0 total input drops
     0 drops for unrecognized upper-level protocol
     Received 65 broadcast packets, 12 multicast packets
     3133 packets output, 132666 bytes, 0 total output drops
     Output 9 broadcast packets, 0 multicast packets


BVI101 is down, line protocol is down
  Interface state transitions: 2
  Hardware is Bridge-Group Virtual Interface, address is 10f3.116c.e6a7
  Internet address is 1.1.1.2/24
  MTU 1514 bytes, BW 10000000 Kbit (Max: 10000000 Kbit)
     reliability 255/255, txload 0/255, rxload 0/255
  Encapsulation ARPA,  loopback not set,
  Last link flapped 8w0d
  ARP type ARPA, ARP timeout 04:00:00
  Last input never, output 8w2d
  Last clearing of "show interface" counters never
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     0 packets input, 0 bytes, 0 total input drops
     0 drops for unrecognized upper-level protocol
     Received 0 broadcast packets, 0 multicast packets
     1 packets output, 42 bytes, 0 total output drops
     Output 1 broadcast packets, 0 multicast packets


BVI201 is up, line protocol is up
  Interface state transitions: 1
  Hardware is Bridge-Group Virtual Interface, address is 10f3.116c.e6a7
  Internet address is 192.168.1.2/24
  MTU 1514 bytes, BW 10000000 Kbit (Max: 10000000 Kbit)
     reliability 255/255, txload 0/255, rxload 0/255
  Encapsulation ARPA,  loopback not set,
  Last link flapped 1w0d
  ARP type ARPA, ARP timeout 04:00:00
  Last input 00:19:00, output 00:19:00
  Last clearing of "show interface" counters never
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     48 packets input, 2880 bytes, 0 total input drops
     0 drops for unrecognized upper-level protocol
     Received 2 broadcast packets, 0 multicast packets
     47 packets output, 1974 bytes, 0 total output drops
     Output 1 broadcast packets, 0 multicast packets


Loopback0 is up, line protocol is up
  Interface state transitions: 1
  Hardware is Loopback interface(s)
  Internet address is 192.168.0.2/32
  MTU 1500 bytes, BW 0 Kbit
     reliability Unknown, txload Unknown, rxload Unknown
  Encapsulation Loopback,  loopback not set,
  Last link flapped 8w2d
  Last input Unknown, output Unknown
  Last clearing of "show interface" counters Unknown
  Input/output data rate is disabled.


Loopback100 is up, line protocol is up
  Interface state transitions: 1
  Hardware is Loopback interface(s)
  Description: finalBVI1
  address is 10f3.116c.e6a7
  Internet address is Unknown
  MTU 1500 bytes, BW 0 Kbit
     reliability Unknown, txload Unknown, rxload Unknown
  Encapsulation Loopback,  loopback not set,
  Last link flapped 8w2d
  Last input Unknown, output Unknown
  Last clearing of "show interface" counters Unknown
  Input/output data rate is disabled.


Null0 is up, line protocol is up
  Interface state transitions: 1
  Hardware is Null interface
  Internet ad
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值