diff options
author | Joseph G <juniorrubyist@gmail.com> | 2018-10-11 14:10:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-11 14:10:16 -0700 |
commit | 56258dfb72c17192d1963d56da6aaf12624b3e43 (patch) | |
tree | e16fc4b7953bce9698eeb131b4a0e789d9359397 | |
parent | 7f782df3376f9d9add847e9f1398606dfce8a0c0 (diff) |
Add f-string clarification.
-rw-r--r-- | python3.html.markdown | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/python3.html.markdown b/python3.html.markdown index b378a8c6..7683bc60 100644 --- a/python3.html.markdown +++ b/python3.html.markdown @@ -139,9 +139,11 @@ 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 +# 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" +# You can basically put any Python statement inside the braces and it will be output in the string. +f"{name} is {len(name)} characters long." # None is an object |