# -*- coding:utf-8 -*- import xmltodict from ncclient import manager ip='ACip地址', m=manager.connect( host=ip, port=830, username='账号', password='密码', hostkey_verify=False, device_params={'name': 'h3c'}, allow_agent=False, look_for_keys=False, timeout=30) data_xml = ''' <top xmlns="http://www.h3c.com/netconf/data:1.0"> <AP> <ManualAP> <AP> <Name></Name> <Model></Model> <CfgSerialID></CfgSerialID> <CfgMacAddress></CfgMacAddress> <RadioNum></RadioNum> <Status></Status> </AP> </ManualAP> </AP> </top> ''' # 发送 NETCONF 查询请求 response = xmltodict.parse(m.get(filter=('subtree', data_xml)).data_xml) ap_info = response.get('data').get('top').get('AP').get('ManualAP').get('AP') for ap in ap_info: print(ap.get('Name'),ap.get('Model'),ap.get('CfgSerialID'),ap.get('CfgMacAddress'),)