mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00: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:
parent
0d211d3419
commit
b6aed7a0b3
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user