我正在尝试使用 dnspython 库,并且对他们在此页面上查询 MX 记录的示例感到有些困惑:www.dnspython.org/examples.html:
import dns.resolver
answers = dns.resolver.query('dnspython.org', 'MX')
for rdata in answers:
print 'Host', rdata.exchange, 'has preference', rdata.preference
在 python CLI 中,一个 dir(answers) 给了我:
['__class__','__delattr__','__delattr__','__delslice__','__dict__','__doc__','__getattr__','__getattribute__','__getitem__','__getslice__','__hash__','__init__',' __iter__','__len__','__module__','__new__','__reduce__','__reduce_ex__','__repr__','__setattr__','__str__','__weakref__','expiration','qname','rdclass' , 'rdtype', '响应', 'rrset']
有两件事让我感到困惑(它们是相关的):