python-guide icon indicating copy to clipboard operation
python-guide copied to clipboard

c02/c02_06

Open utterances-bot opened this issue 1 year ago • 1 comments

2.6 【基础】字符串格式化 — Python中文指南 1.0 documentation

https://python.iswbm.com/c02/c02_06.html

utterances-bot avatar Apr 23 '23 08:04 utterances-bot

还有一些其实也很有用的字符串格式化方法,比如第二种里面的format,后面参数是可以放可迭代类型的,举个例子“{0} {1[0]} {1[1]} {1[2]}”.format(a, [b, c, d])。 还有一个是数字的格式化在第二种和第三种方法里面都可以加一个:来对数字格式化,比如说 “{val:.2f}”.format(随便一个float),f“{num:02X}”

lucksufe avatar Apr 23 '23 08:04 lucksufe