1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-07-31 12:00:34 +02:00

added example for f-string

Literal string interpolation is new in python 3.6 [pep-0498](https://www.python.org/dev/peps/pep-0498/)
This commit is contained in:
理絵子
2018-07-29 11:53:33 +09:00
committed by GitHub
parent 0d211d3419
commit b6aed7a0b3

View File

@@ -138,6 +138,10 @@ len("This is a string") # => 16
# still use the old style of formatting:
"%s can be %s the %s way" % ("Strings", "interpolated", "old") # => "Strings can be interpolated the old way"
# You can also format using f-strings or formatted string literals
name = "Reiko"
f"She said her name is {name}." # => "She said her name is Reiko"
# None is an object
None # => None