структурированные данные Python с использованием netmiko и Genie возвращают строку вместо словаря

#python #networking #automation #genie

Вопрос:

Я не могу понять, почему эта строка кода out = conn.send_command("show ip interface brief", use_genie=True)

возвращает строку вместо словаря, как ожидалось. как я могу это исправить.

Здесь весь код:

 from netmiko import ConnectHandler`  import pprint   connection_info = {  'device_type': 'cisco_ios',  'host': '131.226.`enter code here`217.149',  'port': 22,  'username': 'developer',  'password': 'C1sco12345' }  with ConnectHandler(**connection_info) as conn:  out = conn.send_command_timing("show ip interface brief", use_genie=True)  pprint.pprint(out)   for interface in out.keys():  print(interface)  

Выполнение этого кода приводит к ошибке:

 Traceback (most recent call last):  File "get_interfaces.py", line 17, in lt;modulegt;  for interface in out.keys(): AttributeError: 'str' object has no attribute 'keys'  

В интерпретаторе python я подтвердил, что out-это строка

 gt;gt;gt; type(out) lt;class 'str'gt; gt;gt;gt;   

Спасибо вам за вашу помощь. С уважением