diff options
author | Max Schumacher <maximilianbschumacher@gmail.com> | 2019-12-27 20:18:59 +0100 |
---|---|---|
committer | Max Schumacher <maximilianbschumacher@gmail.com> | 2019-12-27 20:18:59 +0100 |
commit | 071d28d7b6e0610427bac965e71933df955ef1ff (patch) | |
tree | 40767a5b418e6765ec4c633b234c4d615ccd15b3 | |
parent | 83d4b4f5f3dcde817db07388f2f92fca0ec60bc8 (diff) |
Removed deprecated approaches to string interpolation in favor of f-strings
-rw-r--r-- | python3.html.markdown | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/python3.html.markdown b/python3.html.markdown index 2d92de32..d504e2ef 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -136,20 +136,6 @@ b == a # => True, a's and b's objects are equal # You can find the length of a string len("This is a string") # => 16 -# .format can be used to format strings, like this: -"{} can be {}".format("Strings", "interpolated") # => "Strings can be interpolated" - -# You can repeat the formatting arguments to save some typing. -"{0} be nimble, {0} be quick, {0} jump over the {1}".format("Jack", "candle stick") -# => "Jack be nimble, Jack be quick, Jack jump over the candle stick" - -# You can use keywords if you don't want to count. -"{name} wants to eat {food}".format(name="Bob", food="lasagna") # => "Bob wants to eat lasagna" - -# If your Python 3 code also needs to run on Python 2.5 and below, you can also -# 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 (in Python 3.6+) name = "Reiko" f"She said her name is {name}." # => "She said her name is Reiko" |