极简Python学习教程-----format格式化函数

>>>"{} {}".format("hello", "world") # 不设置指定位置,按默认顺序

'hello world'

>>> "{0} {1}".format("hello", "world") # 设置指定位置

'hello world'

>>> "{1} {0} {1}".format("hello", "world") # 设置指定位置

'world hello world'

猜你喜欢

转载自blog.csdn.net/qq_28057379/article/details/105774065