解决 Python 代码中 'Unresolved Reference 'ARP'' 错误
这个错误可能是因为没有正确导入所需的模块或类。在此情况下,需要导入 Scapy 模块中的 ARP 类。可以使用以下代码导入:
from scapy.layers.l2 import ARP
将此行添加到代码的开头即可解决问题。
以下是完整的代码示例:
from scapy.layers.l2 import ARP
arb_table = {}
for pkt in pkts:
if pkt[ARP].opcode == ARP.is_at:
arp_table[pkt[ARP].psrc] = pkt[ARP].hwsrc
with open('arp_table.txt', 'w') as f:
for ip, mac in arp_table.items():
f.write(ip + ' : ' + mac + '\n')
result.insert(tk.END, '扫描完毕,记录保存在 arp_table.txt 文件中。\n')
原文地址: https://www.cveoy.top/t/topic/jnkk 著作权归作者所有。请勿转载和采集!