我有一个包含以下内容的文件:
<html>
<head>
<title> Hello! - {{ today }}</title>
</head>
<body>
{{ runner_up }}
avasd
{{ blabla }}
sdvas
{{ oooo }}
</body>
</html>
{{today}}
提取,{{runner_up}}
等的最好或最 Pythonic 的方法是什么?
我知道可以使用拆分/正则表达式来完成,但我想知道是否还有其他方法。
PS:考虑加载在一个名为的变量中的数据thedata
。
编辑:我认为 HTML 示例很糟糕,因为它将一些评论者引导到 BeautifulSoup。所以,这是一个新的输入数据:
Fix grammatical or {{spelling}} errors.
Clarify meaning without changing it.
Correct minor {{mistakes}}.
Add related resources or links.
Always respect the original {{author}}.
输出:
spelling
mistakes
author