导入python模块的问题
发布时间:2020-12-16 23:44:06 所属栏目:Python 来源:网络整理
导读:我正在尝试在脚本中使用 python的bitstring模块,并且导致导入错误.从交互模式运行时不会发生此错误. 这是代码: import bitstringb = bitstring.BitArray(bin='001001111') 当像这样运行时: python test.py 我明白了: AttributeError: 'module' object has
我正在尝试在脚本中使用
python的bitstring模块,并且导致导入错误.从交互模式运行时不会发生此错误.
这是代码: 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.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |