From a6bcf5f8d7fe60af918eea947bee7f5950a2061d Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 28 Jun 2013 21:20:08 -0700 Subject: [PATCH] Fixes #16: Added new-style string formatting --- python.html.markdown | 7 +++++++ 1 file changed, 7 insertions(+) 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