Python AttributeError: ‘module’ object has no attribute ‘A’
来源:互联网 发布:怎么看淘宝卖家信誉 编辑:程序博客网 时间:2024/05/21 21:36
from: https://dolrblog.wordpress.com/2016/08/24/python-attributeerror-module-object-has-no-attribute-a/
Python AttributeError: ‘module’ object has no attribute ‘A’
One day I am writing a script digging DNS records. A weird error appears during testing:
<class 'dns.rdtypes.ANY.CNAME.CNAME'> Traceback (most recent call last): File "C:\Users\xyz\test.py", line 65, in <module> if isinstance(rr, dns.rdtypes.IN.A.A): AttributeError: 'module' object has no attribute 'A'
The related code is:
import dns.resolver......if rrset: for rr in rrset: if isinstance(rr, dns.rdtypes.IN.A.A): print 'DNS A record:' + domain_name + ':' + rr.address elif isinstance(rr, dns.rdtypes.ANY.CNAME.CNAME): print 'DNS CNAME record:' + domain_name + ':' + rr.target.to_text()
It turns out that, if an instance of class “dns.rdtypes.IN.A.A” is never generated before this “if isinstnace()” line. Python won’t know the class “dns.rdtypes.IN.A.A”. Thus it will raise the error.
So the solution is to explicitly import dns.rdtypes.IN.A, or manually create an A record before the isinstance() check.
0 0
- Python AttributeError: ‘module’ object has no attribute ‘A’
- [Python]attributeError:'module' object has no attribute 'dump'
- [python错误]builtins.AttributeError: 'module' object has no attribute 'request'
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- python AttributeError: 'module' object has no attribute 'setdefaultencoding'
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- python AttributeError: 'module' object has no attribute 'dumps'解决办法
- Python AttributeError: 'module' object has no attribute xxxx
- Python 【精】AttributeError: 'Module' object has no attribute 'STARTF_USESHOWINDOW'
- AttributeError: 'module' object has no attribute 'face' 问题解决 opencv+python
- python 错误解析 AttributeError: 'module' object has no attribute 'dumps'
- 【python】AttributeError: 'module' object has no attribute 'HTTPSConnection'
- Python 2.7.3 AttributeError: 'module' object has no attribute 'urlopen'
- Python:AttributeError: ‘module’ object has no attribute ‘ArgumentParser’
- Python 错误:AttributeError: 'module' object has no attribute
- python opencv:AttributeError: 'module' object has no attribute 'cv' FOURCC
- Python错误AttributeError: 'module' object has no attribute 'copy'
- AttributeError: 'module' object has no attribute 'getpass'
- 在mysql中实现将当前的时间作为建表时的表名
- angularJS中的过滤器filter的用法
- Hi3531a+adv7611 driver 调试过程
- android(体验一个项目天气预报开发)-3
- 浅谈react受控组件与非受控组件
- Python AttributeError: ‘module’ object has no attribute ‘A’
- solr常用命令总结
- Java多线程/并发04、synchronized同步
- BZOJ 3105: [cqoi2013]新Nim游戏
- 编写java程序151条建议读书笔记(4)
- c 调用gtk剪贴板
- jquery extend 解析
- hadoop 2.7.3 单机模式
- JavaScript学习笔记20-while循环