Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0ec8c4b commit f361897Copy full SHA for f361897
1 file changed
Doc/reference/lexical_analysis.rst
@@ -676,6 +676,12 @@ Some examples of formatted string literals::
676
>>> value = decimal.Decimal("12.34567")
677
>>> f"result: {value:{width}.{precision}}" # nested fields
678
'result: 12.35'
679
+ >>> today = datetime(year=2017, month=1, day=27)
680
+ >>> f"{today:%b %d, %Y}" # using date format specifier
681
+ 'January 27, 2017'
682
+ >>> number = 1024
683
+ >>> f"{number:#0x}" # using integer presentation type as format specifier
684
+ '0x400'
685
686
A consequence of sharing the same syntax as regular string literals is
687
that characters in the replacement fields must not conflict with the
0 commit comments