以太对象不可调用-python

Ether object is not callable-python

我正在尝试使用 scapy 为 nslookup 编写代码。当我 运行 它时,它说:

TypeError: 'Ether' object is not callable

它指向这一行:print(ans(ether(ip.src)))

谁能告诉我如何解决这个问题?

您的 Scapy 语法已关闭。应该是

print(ans[IP].src)

而不是

print(ans(ether(ip.src)))

我看不出 Ether 部分与此有什么关系。我觉得你写nslookup的方法和我不一样。