其中,最后一句 print 有点看不太明白,{0} == {1}是什么意思呢? 请各位大神帮忙解释一下,多谢。
1
co3site 2016 年 7 月 1 日
"{0} == {1}".format(key, value) -> str.format(key, value)
|
2
mgna17 2016 年 7 月 1 日
就是个替换呗,这里的 {0}, {1} 分别对应 format 中的参数
format(...) method of builtins.str instance S.format(*args, **kwargs) -> str Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces ('{' and '}'). |
3
Allianzcortex 2016 年 7 月 1 日
等价于 print'{} == {}'.format(key,value) 比 print '%s == %s' %(key,value) 要好
|
4
cloverstd 2016 年 7 月 1 日
其实还有 print("{key} == {value}".format(key=key, value=value))
|
5
yexiaoxing 2016 年 7 月 1 日 via iPad |
6
linuxchild 2016 年 7 月 2 日 via Android
大括号和双等是分开的……说起来这个执行一下不就知道了吗
|