summaryrefslogtreecommitdiffhomepage
path: root/python3.html.markdown
diff options
context:
space:
mode:
author理絵子 <41843094+lowlevelware@users.noreply.github.com>2018-07-29 11:53:33 +0900
committerGitHub <noreply@github.com>2018-07-29 11:53:33 +0900
commitb6aed7a0b38bf189922dbc47ed802de3c9769b73 (patch)
tree5fde0838bd71e11f1512b16a64b05345049b9838 /python3.html.markdown
parent0d211d341913305bd1d97e5d097898eb7faa1354 (diff)
added example for f-string
Literal string interpolation is new in python 3.6 [pep-0498](https://www.python.org/dev/peps/pep-0498/)
Diffstat (limited to 'python3.html.markdown')
-rw-r--r--python3.html.markdown4
1 files changed, 4 insertions, 0 deletions
diff --git a/python3.html.markdown b/python3.html.markdown
index 019934cb..d6cfbf59 100644
--- a/python3.html.markdown
+++ b/python3.html.markdown
@@ -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