mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Add one more string formatting example
This commit is contained in:
parent
927ac9c3e8
commit
db903ac5b6
@ -128,6 +128,7 @@ not False # => True
|
||||
|
||||
# A newer way to format strings is the format method.
|
||||
# This method is the preferred way
|
||||
"{} is a {}".format("This", "placeholder")
|
||||
"{0} can be {1}".format("strings", "formatted")
|
||||
# You can use keywords if you don't want to count.
|
||||
"{name} wants to eat {food}".format(name="Bob", food="lasagna")
|
||||
|
Loading…
Reference in New Issue
Block a user