File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 7575
7676其实,上面这种格式化方法,常常被认为是太“古老”了。因为在python中还有新的格式化方法。
7777
78- >>> s1 = "I like {}".format("python")
78+ >>> s1 = "I like {0 }".format("python")
7979 >>> s1
8080 'I like python'
81- >>> s2 = "Suzhou is more than {} years. {} lives in here.".format(2500, "qiwsir")
81+ >>> s2 = "Suzhou is more than {0 } years. {1 } lives in here.".format(2500, "qiwsir")
8282 >>> s2
8383 'Suzhou is more than 2500 years. qiwsir lives in here.'
8484
85- 这就是python非常提倡的` string.format() ` 的格式化方法,其中` {} ` 作为占位符。
85+ 这就是python非常提倡的` string.format() ` 的格式化方法,其中` {索引值 } ` 作为占位符,
8686
8787这种方法真的是非常好,而且非常简单,只需要将对应的东西,按照顺序在format后面的括号中排列好,分别对应占位符` {} ` 即可。我喜欢的方法。
8888
267267
268268[ 总目录] ( ./index.md )   ;  ;  ; |  ;  ;  ; [ 上节:字符串(3)] ( ./108.md )   ;  ;  ; |  ;  ;  ; [ 下节:字符编码] ( ./110.md )
269269
270- 如果你认为有必要打赏我,请通过支付宝:** qiwsir@126.com ** ,不胜感激。
270+ 如果你认为有必要打赏我,请通过支付宝:** qiwsir@126.com ** ,不胜感激。
You can’t perform that action at this time.
0 commit comments