import re
import json
html = """
<ul>
    <li>Name: $name01</li>
    <li>Age: $age01</li>
</ul>"""
JSON = '{"name01":"Joe", "age01":"25"}'
data = json.loads(JSON)
html = re.sub('\\$(\\w+)', lambda m: data[m.group(1)], html)
print(html)
How to replace values from JSON with those found by RegEx in a file using Python?