Merge pull request #1847 from cnu/master

Add one more string formatting example
This commit is contained in:
Spurlow 2015-10-31 19:24:19 +08:00
commit 0e2b669c17

View File

@ -132,6 +132,7 @@ z = "The items in the basket are %s and %s" % (x,y)
# 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")