1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
字符串追加和拼接 通过字符串的占位符来进行字符串的拼接 #1 元组拼接 m = 'python' astr = 'i love %s' % m print astr #2 字符串的format方法 m = 'python' astr = "i love {python}".format(python=m) print astr #3 字典格式化字符串 m = 'python' astr = "i love %(python)s " % {'python':m} print astr |
