import re
a="""
interface Eth-Trunk152.190
mtu 9000
description TO-[S-RT-02]-100GE 5/1/0.190
ip binding vpn-instance GaRf_DMZ
ipv6 enable
ip address 10.246.148.10 255.255.255.252
ipv6 address 2001:3333:973:2001:202::201/127
ipv6 mtu 9000
dot1q termination vid 190
ospfv3 190 area 0.0.0.0
ospfv3 network-type p2p
ospfv3 authentication-mode hmac-sha256 key-id 1 cipher 2222222
ospf authentication-mode md5 1 cipher 2222222
ospf network-type p2p
undo service-manage enable
"""
b=(r"interface (.*)",
r" mtu (\d+)",
r" description (.*)",
r" ip binding vpn-instance (.*)")
d="\n".join(b)
print(re.findall(d,a))
我想统计接口名称 mtu大小等信息。
上面的脚本可以统计出来这些信息。但是有些接口没有mtu这条,没有办法匹配出来。怎么修改下脚本