Python print format() 格式化内置函数

Python2.6 开始,新增了一种格式化字符串的函数 str.format(),它增强了字符串格式化的功能。

基本语法是通过 {} 和 : 来代替以前的 % 。

format 函数可以接受不限个参数,位置可以不按顺序。

还可以格式化数字:

详细介绍:http://www.runoob.com/python/att-string-format.html

原文地址:https://www.cnblogs.com/itfat/p/7455253.html