You can go with formatted string literals ("f-strings") since Python 3.6

f"Hi {name}, you are {age}"

Or string formatting

"Hi {}, you are {}".format(name, age)
"Hi {name}, you are {age}".format(name=name, age=age)

Or format specifiers

"Hi %s, you are %d" % (name, age)
Answer from Abhilash on Stack Overflow
๐ŸŒ
Python
peps.python.org โ€บ pep-0750
PEP 750 โ€“ Template Strings - Python Enhancement Proposals
July 8, 2024 - Like Template, it is a new class found in the string.templatelib module: class Interpolation: value: object expression: str conversion: Literal["a", "r", "s"] | None format_spec: str __match_args__ = ("value", "expression", "conversion", "format_spec") def __new__( cls, value: object, expression: str = "", conversion: Literal["a", "r", "s"] | None = None, format_spec: str = "", ): ...
Discussions

Coming from JavaScript, what's the python equivalent to string template literals?
not sure why no one is just posting it f'name is {name} and age is {age}' Single or double quotes More on reddit.com
๐ŸŒ r/learnpython
18
6
March 26, 2022
Add tagged template literals - Ideas - Discussions on Python.org
Feature or enhancement Thanks for such a great language and ecosystems! And I love Pythonโ€™s f-string. I zapped some website, Javascript has Tagged template literals, and it is a powerful feature. Template literals (Template strings) - JavaScript | MDN Tagged Template Literals - Wes Bos Pitch ... More on discuss.python.org
๐ŸŒ discuss.python.org
0
July 26, 2022
Printing template literals in python "{item}" vs. "{}.format(item)"
Amanda Esping is having issues with: Is there a reason why/helpful way to remember which format literal is used where? In most of the places I've learned so far, it works like this:... More on teamtreehouse.com
๐ŸŒ teamtreehouse.com
2
June 14, 2021
PEP 501: (reopen) General purpose string template literals - PEPs - Discussions on Python.org
With collaboration with Nick Coghlan (the original author of PEP 501), we would like to propose reopening PEP 501 after 7 years of being differed. In those seven years, f-strings have become common idiomatic python, and people are familiar and comfortable with them. More on discuss.python.org
๐ŸŒ discuss.python.org
6
March 9, 2023
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ string.templatelib.html
string.templatelib โ€” Support for template string literals
>>> pi = 3.14 >>> t't-strings are ... be reassigned. The most common way to create a Template instance is to use the template string literal syntax....
๐ŸŒ
Medium
medium.com โ€บ @charliesharding โ€บ learning-python-no-template-literals-da7cbd77e3ba
Learning Python โ€” Template Literals? | by Charles Harding | Medium
June 19, 2019 - Coming from Javascript, python is a fairly approachable language. Iโ€™m going to try to keep up these posts as a reference for others learning python as well. One of the first things that Iโ€™ve encountered is the absence of template literals in the language.
๐ŸŒ
Real Python
realpython.com โ€บ python-t-strings
Python 3.14: Template Strings (T-Strings) โ€“ Real Python
July 2, 2025 - In the next section, youโ€™ll get to know how t-strings work and how they differ from f-strings. T-strings are a generalization of f-strings. The literal of a t-string starts with a t or T, in place of the f or F prefix used in f-strings:
๐ŸŒ
LaunchCode
education.launchcode.org โ€บ lchs โ€บ chapters โ€บ strings โ€บ template-literals.html
7.7. Template Literals โ€” LaunchCode's LCHS documentation
Also, concatenation usually requires several test runs of the code in order to check for syntax errors and proper spacing. Fortunately, Python offers us a better way to accomplish the same thing. Template literals allow for the automatic insertion of expressions and variable values into strings.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ template-class-in-python
String Template Class in Python - GeeksforGeeks
July 23, 2025 - Explanation: This code creates a template with placeholders $name and $city, then prints the original template string using the .template attribute without performing any substitutions. Since $ is used to mark placeholders, you must use $$ if you want a literal dollar sign $ in your output.
๐ŸŒ
Python
peps.python.org โ€บ pep-0501
PEP 501 โ€“ General purpose template literal strings | peps.python.org
August 8, 2015 - The template string is parsed into literals, expressions, format specifiers, and conversion specifiers as described for f-strings in PEP 498 and PEP 701. The syntax for conversion specifiers is relaxed such that arbitrary strings are accepted (excluding those containing {, } or :) rather than being restricted to valid Python identifiers.
๐ŸŒ
Python.org
discuss.python.org โ€บ ideas
Add tagged template literals - Ideas - Discussions on Python.org
July 26, 2022 - Template literals (Template strings) ... functionality to f-string, but allows the value to be passed through a specific function before embedding, or to be reformatted for the entire resulting string....
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ string.html
string โ€” Common string operations
Advanced usage: you can derive subclasses of Template to customize the placeholder syntax, delimiter character, or the entire regular expression used to parse template strings. To do this, you can override these class attributes: delimiter โ€“ This is the literal string describing a placeholder introducing delimiter.
๐ŸŒ
Towards Data Science
towardsdatascience.com โ€บ home โ€บ latest โ€บ python template string formatting method
Python Template String Formatting Method | Towards Data Science
January 21, 2025 - >>> Template('$obj. is $$$colour').substitute(obj='Car',colour='red') 'Car. is $red' Iโ€™m still a beginner in Python and comparing String formatting methods taught me a lot. I hope I was clear in providing the details to you.
๐ŸŒ
Python
docs.python.org โ€บ 2.4 โ€บ lib โ€บ node109.html
4.1.2 Template strings
December 15, 2019 - Advanced usage: you can derive subclasses of Template to customize the placeholder syntax, delimiter character, or the entire regular expression used to parse template strings. To do this, you can override these class attributes: delimiter - This is the literal string describing a placeholder ...
๐ŸŒ
InfoWorld
infoworld.com โ€บ home โ€บ software development โ€บ programming languages โ€บ python
How to use template strings in Python 3.14 | InfoWorld
September 26, 2025 - The function clean() takes in a template string and cleans it in such a way that any HTML brackets (< and > ) will be changed to harmless literals ( &lt; and &gt;).
Top answer
1 of 2
8
Hey @amandae (https://teamtreehouse.com/amandae), There are many ways to format a string (https://docs.python.org/3/tutorial/inputoutput.html#input-and-output) in Python. The f-strings (https://docs.python.org/3/tutorial/inputoutput.html#formatted-string-literals), formatted string literals, is the latest addition, first appearing in Python 3.6 (https://docs.python.org/3/whatsnew/3.6.html#pep-498-formatted-string-literals). The more complex (and flexible) previous method is using the str.format() (https://docs.python.org/3/tutorial/inputoutput.html#the-string-format-method) method. This is is still widely used, and has additional features (like repeatable, reorderable fields) so expect it to stick around for a long time. With the format method, the {} placeholders can taking on many forms: * as order-dependent placeholders when empty: "{} before {}".format(first, last) * as indexed-dependent placeholders when numbered: "{1} before {0}".format(goes2zero, goes2one) * as named placeholders: "{first} before {last}".format(first=goes2first, last=goes2last) So, about remembering the difference. The "f" in front of f-strings can be thought of as fancy, where it is a shortcut to the named placeholder version of format without having to add the .format(first=first, last=last) method. The "f" can also be thought of as fast, since f-stings have been optimized to be the fasted string handling in python!! Post back if you need more help. Good luck!!
2 of 2
0
Thank you so much! Your answer is wonderfully helpful!
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ formatting-strings-with-the-python-template-class
Formatting Strings with the Python Template Class
September 19, 2021 - We'll then have a look at how we can change the way our Templates can substitute data into strings. For a better understanding of these topics, you'll require some basic knowledge on how to work with classes and regular expressions. The Python Template class was added to the string module since Python 2.4.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ string-interpolation
Python String Interpolation
For instance, if you have a template for saying hello to a person like "Hello {Name of person}, nice to meet you!", you would like to replace the placeholder for name of person with an actual name. This process is called string interpolation. Python 3.6 added new string interpolation method called literal ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ string-templates-in-python
String templates in Python
String templates in Python simplify generating dynamic outputs while separating program logic from output formats. Using the string.Template class with methods like substitute() and safe_substitute(), developers can create customizable web pages, reports, and XML files efficiently.
๐ŸŒ
Python.org
discuss.python.org โ€บ peps
PEP 501: (reopen) General purpose string template literals - PEPs - Discussions on Python.org
March 9, 2023 - With collaboration with Nick Coghlan (the original author of PEP 501), we would like to propose reopening PEP 501 after 7 years of being differed. In those seven years, f-strings have become common idiomatic python, and โ€ฆ
๐ŸŒ
Medium
medium.com โ€บ @bluebirz โ€บ 3-ways-for-python-string-template-71d2bb5d3de1
3 ways for Python string template | by bluebirz | Medium
January 28, 2025 - With .render() we supply the parameter variables specified in {{}} in the template.