我们格式化构建字符串可以有3种方法:
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
转载于:https://www.cnblogs.com/chenya/p/4218967.html