Python - Template Strings
Last Updated: 2350Z 29MAR21
(Created: 2349Z 29MAR21)
Template strings are the preferred approach when handling user supplied text to avoid security issues.
Examples:
from string import Template
TEMPLATE='$greeting $name!'
data = {
'greeting': 'Hello',
'name': 'Bob'
}
print(Template(TEMPLATE).substitute(data))
"""
$ python3 test_str_template.py
Hello Bob!
"""
References: