程序:
from netmiko import ConnectHandler
iosv_l2 = {
'device_type': 'cisco_ios',
'ip': '192.168.122.50',
'username': 'sagar',
'password': 'sagar',
}
net_connect =ConnectHandler(**iosv_l2)
output =net_connect.send_command('show ip int brief')
print(output)
config_commands = [ 'int loop 0', 'ip addre 1.1.1.1 255.255.255.0']
output = net_connect.send_config_set(config_commands)
print (output)
错误:
Traceback (most recent call last):
File "netmiko1", line 3, in <module>
from netmiko import ConnectHandler
File "/usr/local/lib/python2.7/dist-packages/netmiko/__init__.py", line 7, in <module>
from netmiko.ssh_dispatcher import ConnectHandler
File "/usr/local/lib/python2.7/dist-packages/netmiko/ssh_dispatcher.py", line 2, in <module>
from netmiko.a10 import A10SSH
File "/usr/local/lib/python2.7/dist-packages/netmiko/a10/__init__.py", line 1, in <module>
from netmiko.a10.a10_ssh import A10SSH
File "/usr/local/lib/python2.7/dist-packages/netmiko/a10/a10_ssh.py", line 3, in <module>
from netmiko.cisco_base_connection import CiscoSSHConnection
File "/usr/local/lib/python2.7/dist-packages/netmiko/cisco_base_connection.py", line 143
msg = f"Login failed: {self.host}"
^
SyntaxError: invalid syntax