diff options
author | Geoff Liu <cangming.liu@gmail.com> | 2015-10-29 23:26:59 +0800 |
---|---|---|
committer | Geoff Liu <cangming.liu@gmail.com> | 2015-10-29 23:26:59 +0800 |
commit | ba4cbab87af50533e204d10ab175975a75bb664e (patch) | |
tree | 3957300ef9a6447bc3b958add7a49341cd09db83 /python.html.markdown | |
parent | 7119a37a4ed261f677c9c3401fb981615223f058 (diff) | |
parent | cdd64ecee34af20ed101ba5dc8d7dc73a8189c15 (diff) |
Merge pull request #1676 from vipulroxx/patch-1
Modified string format [python/en]
Diffstat (limited to 'python.html.markdown')
-rw-r--r-- | python.html.markdown | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/python.html.markdown b/python.html.markdown index 753d6e8c..541bd36d 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -123,8 +123,12 @@ 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") +#String formatting with % +#Even though the % string operator will be deprecated on Python 3.1 and removed +#later at some time, it may still be good to know how it works. +x = 'apple' +y = 'lemon' +z = "The items in the basket are %s and %s" % (x,y) # A newer way to format strings is the format method. # This method is the preferred way |