mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.14] gh-132661: Document t-strings and templatelib (GH-135229) (#136974)
Co-authored-by: Dave Peck <davepeck@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Loïc Simon <loic.pano@gmail.com> Co-authored-by: pauleveritt <pauleveritt@me.com> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
This commit is contained in:
parent
d118bc061b
commit
c59a60bdb4
10 changed files with 488 additions and 23 deletions
|
|
@ -95,10 +95,11 @@ Some examples::
|
|||
>>> repr((x, y, ('spam', 'eggs')))
|
||||
"(32.5, 40000, ('spam', 'eggs'))"
|
||||
|
||||
The :mod:`string` module contains a :class:`~string.Template` class that offers
|
||||
yet another way to substitute values into strings, using placeholders like
|
||||
``$x`` and replacing them with values from a dictionary, but offers much less
|
||||
control of the formatting.
|
||||
The :mod:`string` module also contains support for so-called
|
||||
:ref:`$-strings <template-strings-pep292>` that offer yet another way to
|
||||
substitute values into strings, using placeholders like ``$x`` and replacing
|
||||
them with values from a dictionary. This syntax is easy to use, although
|
||||
it offers much less control of the formatting.
|
||||
|
||||
.. index::
|
||||
single: formatted string literal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue