Dnspython无法解决任何问题

2024-06-16 13:56:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我的示例代码是

import dnspython as dns
import dns.resolver

result = dns.resolver.query('google.com', 'A')
for ipval in result:
    print('IP', ipval.to_text())

这给了我一个错误 dns.resolver.NoResolverConfiguration: Resolver configuration could not be read or specified no nameservers.

/etc/resolv.conf包含“1.1.1.1”,除此之外没有其他内容,netplan名称服务器也设置为1.1.1.1

机器正在ubuntu 20.04上运行python 3.8.5

为什么它会给我这个错误?我如何解决它


Tags: 代码inimportcom示例fordnsas