我的示例代码是
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。
为什么它会给我这个错误,我如何解决它?
发布于 2020-12-13 12:36:14
想明白了!
巨大的脸部软膏。我忘了在/etc/resolv.conf上放置nameserver 1.1.1.1,而不仅仅是1.1.1.1
因此,确实,配置是错误的。
https://stackoverflow.com/questions/65272373
复制相似问题