0
私はpythonスクリプトを使って編集したいHTMLページを持っています。私はDominateライブラリを使用していますPython 3.5.2とDominateを使ってHTMLページを編集する
ここはベアボーンの例です。
<html>
<head>
<title>asdjasda</title>
</head>
<body>
<h1>THIS IS A TEST</h1>
</body>
</html>
単純なHTMLの権利ですか?
import dominate
from dominate.tags import *
page = open('index.html','r',encoding='utf-8')
with page.head:
link(rel='stylesheet', href='tts.css')
page.close()
私はこのスクリプトを実行すると、私は次のエラーを取得する:
はここで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には「頭」があります。
私のファイルを支配する方法を教えてください。
これは機能しますが、何らかの理由でドキュメント全体が壊れてしまいます。また、オリジナルのHTMLファイル – YaddyVirus
に変更はありません。本体のh1タグを 'title'タグの内側に入れます。 – YaddyVirus
そして、私のindex.htmlファイルをクリアしました – YaddyVirus