我正在尝试使用 pythonbitstring
脚本中的模块并收到导入错误。从交互模式运行时不会发生此错误。
这是代码:
import bitstring
b = bitstring.BitArray(bin='001001111')
当这样运行时:
python test.py
我明白了:
AttributeError: 'module' object has no attribute 'BitArray'
但是,当我这样做时:
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bitstring
>>> b = bitstring.BitArray(bin='001001111')
>>> print b
0b001001111
效果很好!这是由同一用户运行的同一解释器。有什么指点吗?
我预测您已经在当前目录中创建了一个 bitstring.py 。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)