我能够使用以下 netmiko 代码获取设备主机名。
>>> print(net_connect.find_prompt())
Cisco#
>>>
>>> print(net_connect.send_command('show running-config | include hostname'))
hostname Cisco
>>>
是否可以从输出中删除#
和hostname
?
期望的输出
>>> print(net_connect.find_prompt()) <= need to do something here
Cisco
>>>
>>> print(net_connect.send_command('sh run | i host')) <= need to do something here
Cisco
>>>