标签:一个 符号 orm span 运用 div strong color col
1.format后面都是个元组类型!!!
不一一对应则报错,比如少了一个替换的元素
括号里可以加索引,看例2
可以用索引只取一个值,比如括号里都是{1}
r = "i am {}, i am {} yearsold".format("nana",18) print(r) i am nana, i am 18 yearsold
r = "i am {1}, i am {0} yearsold".format("nana",18) print(r) i am 18, i am nana yearsold
2.注意后面用小括号,根据format语法运用符号
也可以用字典的形式,但是注意加*号以及中括号,比如例2
r = "i am {name}, i am {age} yearsold".format(name = "nana",age = 18) print(r) i am nana, i am 18 yearsold
r = "i am {name}, i am {age} yearsold".format(**{"name": "nana","age":18}) print(r) i am nana, i am 18 yearsold
3.
标签:一个 符号 orm span 运用 div strong color col
原文地址:https://www.cnblogs.com/newt/p/8987883.html