导入python模块的问题 [英] problems importing python module

查看:126
本文介绍了导入python模块的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在脚本中使用python的 bitstring 模块,并且收到导入错误。从交互模式运行时不会发生此错误。

I'm trying to use python's bitstring module in a script and am getting an import error. This error does not happen when running from interactive mode.

以下是代码:

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

它运作正常!它是由同一用户运行的相同解释器。任何指针?

It works just fine! It's the same interpreter being run by the same user. Any pointers?

推荐答案

我预测你在当前目录中创建了一个bitstring.py。

I predict you have created a bitstring.py in your current directory.

这篇关于导入python模块的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆