Skip to content

Commit ac54965

Browse files
committed
Merge pull request qiwsir#25 from dongm2ez/master
Update 109.md
2 parents e587d58 + 5f281e1 commit ac54965

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

109.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@
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

@@ -267,4 +267,4 @@
267267

268268
[总目录](./index.md)   |   [上节:字符串(3)](./108.md)   |   [下节:字符编码](./110.md)
269269

270-
如果你认为有必要打赏我,请通过支付宝:**qiwsir@126.com**,不胜感激。
270+
如果你认为有必要打赏我,请通过支付宝:**qiwsir@126.com**,不胜感激。

0 commit comments

Comments
 (0)