我正在尝试将 ElementTree 对象写入磁盘。一切正常,除了输出文件如下所示:
<html:html lang="en-US" xml:lang="en-US" xmlns:html="http://www.w3.org/1999/xhtml">
<html:head>
<html:title>vocab</html:title>
<html:style type="text/css"> ...
由于它有html:
命名空间信息,浏览器无法呈现它。
如何让 etree 在没有html:
命名空间信息的情况下将一些 html 保存到磁盘?
这是我用来编写的代码:
with open('/path/to/file.html', mode='w', encoding='utf-8') as outfile:
mypage.write(outfile)
谢谢!