我有一个HTML页面,我想用python脚本编辑它。我正在使用Dominate库
这是一个简单的例子。在
<html>
<head>
<title>asdjasda</title>
</head>
<body>
<h1>THIS IS A TEST</h1>
</body>
</html>
简单的HTML对吗?
下面是python脚本:
运行此脚本时,出现以下错误。在
Traceback (most recent call last):
File "script.py", line 6, in <module>
with page.head:
AttributeError: '_io.TextIOWrapper' object has no attribute 'head'
我的HTML确实有一个“头”。在
如何使用dominate编辑我的文件?在
原因是
open()
函数返回的内容没有head
属性。在您应该使用支配库中的
document
。在试试这个:
希望有帮助!在
相关问题 更多 >
编程相关推荐