当前位置: 首页 > 工具软件 > IP resolver > 使用案例 >

DeprecationWarning: please use dns.resolver.Resolver.resolve() 解决

吕飞翼
2023-12-01

警告提示为:
DeprecationWarning: please use dns.resolver.Resolver.resolve()

警告源代码类似下面:


 # my_resolver = dns.resolver.Resolver()
        my_resolver = dns.resolver.Resolver.resolve()
        answers = my_resolver.query(host, "A")
        answer_txt = my_resolver.query(host, "TXT")

You should remove .resolve from my_resolver = dns.resolver.Resolver.resolve() and replace my_resolver.query() with my_resolver.resolve()

然后在源代码中把query改成resolver


my_resolver = dns.resolver.Resolver()
    answers = my_resolver.resolve(host, "A")
    answer_txt = my_resolver.resolve(host, "TXT")
 类似资料: