Python 3.3.2:html模块导入时出错

时间:2013-10-03 14:24:54

标签: python python-3.x

我在Windows 7上安装了Python 3.3.2。我正在尝试使用文档中的示例导入 html.parser.HTMLParser Simple HTML and XHTML parser

但是我收到了错误:

>>> from html.parser import HTMLParser
aee4
gg2
Traceback (most recent call last):
  File "htmlang.py", line 1, in <module>
    from html.parser import HTMLParser
  File "c:\Python33\lib\html\parser.py", line 13, in <module>
    import warnings
  File "c:\Python33\lib\warnings.py", line 6, in <module>
    import linecache
  File "c:\Python33\lib\linecache.py", line 10, in <module>
    import tokenize
  File "c:\Python33\lib\tokenize.py", line 37, in <module>
    __all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding",
AttributeError: 'module' object has no attribute '__all__'

我刚打开解释器并输入了导入行。为什么它没有按预期工作?为什么要打印奇怪的“aee4”和“gg2”字符串?

1 个答案:

答案 0 :(得分:-1)

只需编写“import HTMLParser”即可使用