mirror of
https://github.com/python/cpython.git
synced 2026-01-04 14:32:21 +00:00
gh-132661: Document t-strings and templatelib (#135229)
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>
This commit is contained in:
parent
9a21df7c0a
commit
22c8658906
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