gpt4 book ai didi

networking - Netmiko:如何使用变量在交换机中搜索

转载 作者:行者123 更新时间:2023-12-04 07:38:41 25 4
gpt4 key购买 nike

如果我这样做,我不会得到任何输出。

mac_address=abcd
output=net_connect.send_command('show mac-address-table | inc mac_address')
print("Output of the switch ",output)


如果我这样做,我将获得所需的输出。
output=net_connect.send_command('show mac-address-table | inc abcd')
print("Output of the switch ",output)


我应该在代码中进行哪些更改才能使用变量?

最佳答案

第一个例子中的结束引号在 mac_address 之后,使文字文本,而不是变量。我不确定您如何附加两个字符串,但类似于:

output=net_connect.send_command('show mac-address-table | inc '+mac_address)
哪里 +附加文字字符串和变量字符串。

关于networking - Netmiko:如何使用变量在交换机中搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67610610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com