タグの後のすべてを取得し'</html>'
て削除しようとしていますが、コードは何も実行していないようです。.replace()
正規表現をサポートしていないのでしょうか?
z.write(article.replace('</html>.+', '</html>'))
ベストアンサー1
いいえ。Pythonの正規表現は、re
モジュール。
article = re.sub(r'(?is)</html>.+', '</html>', article)
一般的に:
str_output = re.sub(regex_search_term, regex_replacement, str_input)