diff options
author | Adam <adam@adambard.com> | 2013-06-28 21:20:08 -0700 |
---|---|---|
committer | Adam <adam@adambard.com> | 2013-06-28 21:20:08 -0700 |
commit | a6bcf5f8d7fe60af918eea947bee7f5950a2061d (patch) | |
tree | 6ef6b011ab87cf2ee2bc911f5a965cc25314fcd6 /python.html.markdown | |
parent | 4789dd1097ea3980374715eaac7852552d2fa036 (diff) |
Fixes #16: Added new-style string formatting
Diffstat (limited to 'python.html.markdown')
-rw-r--r-- | python.html.markdown | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/python.html.markdown b/python.html.markdown index 3127cf2e..463556d9 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -80,6 +80,13 @@ not False #=> True # A string can be treated like a list of characters "This is a string"[0] #=> 'T' +# % can be used to format strings, like this: +"%s can be %s" % ("strings", "interpolated") + +# A newer way to format strings is the format method. +# This method is the preferred way +"{0} can be {1}".format("strings", "formatted") + # None is an object None #=> None |