为什么我会收到re.error:位置0处的不平衡括号错误在这里?

问题描述

我正在尝试使用带有功能send_config_set()的ssh将一些配置发送到我的netgear交换机

Netgear_M4100_66={'device_type':'netgear_prosafe','host':'172.16.97.66','username':'admin','password':'******',}
    

all_devices=[Netgear_M4100_66]
config_commands=['interface vlan 97']

    
for device in all_devices:    
    
    net_connect = ConnectHandler(**device,fast_cli=True)
    net_connect.enable()
    net_connect.send_config_set(config_commands)
    output=net_connect.send_command('show port status all')
    print("\n\n------------- Device {0} = {1} -------------".format(device['device_type'],device['host']))
    print(output)
    print("----------- End ------------")

这是回溯

`Traceback (most recent call last):
File "add_Switch_netmiko.py",line 118,in <module>
options()
File "add_Switch_netmiko.py",line 99,in options
config_mehrere_Switche()
File "add_Switch_netmiko.py",line 80,in config_mehrere_Switche 
net_connect.send_config_set(config_commands)
File "/usr/local/lib/python3.6/dist-packages/netmiko/base_connection.py",line 1837,in send_config_set
output += self.config_mode(*cfg_mode_args)
File "/usr/local/lib/python3.6/dist- 
packages/netmiko/netgear/netgear_prosafe_ssh.py",line 29,in config_mode
return super().config_mode(config_command=config_command,pattern=pattern)
File "/usr/local/lib/python3.6/dist- 
packages/netmiko/cisco_base_connection.py",line 41,in config_mode
config_command=config_command,pattern=pattern,re_flags=re_flags
File "/usr/local/lib/python3.6/dist-packages/netmiko/base_connection.py",line 1728,in config_mode
if not re.search(pattern,output,flags=re_flags):
File "/usr/lib/python3.6/re.py",line 182,in search
return _compile(pattern,flags).search(string)
File "/usr/lib/python3.6/re.py",line 301,in _compile
p = sre_compile.compile(pattern,flags)
File "/usr/lib/python3.6/sre_compile.py",line 562,in compile
p = sre_parse.parse(p,flags)
File "/usr/lib/python3.6/sre_parse.py",line 869,in parse
raise source.error("unbalanced parenthesis")
sre_constants.error: unbalanced parenthesis at position 0`

在查看了互联网上的所有示例之后,这应该可以工作,但不幸的是,它没有工作。我认为问题可能出在python3.6上,所以我将其升级到了最新的python3.8,但仍然遇到相同的问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)