0
在html5lib
教程的第一步中,我看到了很混乱的行为。html5lib返回<None>
的docs讲述:
import html5lib
f = open("mydocument.html")
doc = html5lib.parse(f)
这将在自定义 “simpletree” 格式返回一棵树。
作为文件我有一个正常的html文档。但在我的情况下,这是:
<None>
>>> doc is None
False
我相信这是不行,但我不知道会发生什么。
编辑
如果我呼吁打开文件read
方法是返回文件作为字符串:
f = open("mydocument.html")
f.read()
# returns string with html
而经过doc = html5lib.parse(f)
,f.read()
返回空字符串,如文件的文件已经被读取。
mydocument.html包含...? –
ofcourse,这是从redmine的登录页复制的html文件=),我使用完整路径,如'/ home/user/file.html' – I159