for item_agent in list_agent:
for item_bk in list_bk:
# for item_agent in list_agent:
if item_bk['ipaddr']==item_agent['ip']:
list_bothhave.append({'username':item_bk['admin'],'ip':item_agent['ip'],'hostname':item_agent['hostname']})
list_bk.remove(item_bk)
# bk_host_list.remove(item_bk)
list_lack=list_bk
for的对象是list内有dict
remove函数正确生效需要
如果for的顺序颠倒,最终结果会比正确结果偏少
原因未知,疑惑中,期待大神解答