Manual
Convert a value to a “formatted” representation, as controlled by format_spec. The interpretation of format_spec will depend on the type of the value argument, however there is a standard formatting syntax that is used by most built-in types: Format Specification Mini-Language.
The default format_spec is an empty string which usually gives the same effect as calling str(value).
A call to format(value, format_spec) is translated to type(value).__format__(value, format_spec) which bypasses the instance dictionary when searching for the value’s __format__() method. A TypeError exception is raised if the method search reaches object and the format_spec is non-empty, or if either the format_spec or the return value are not strings.
Changed in version 3.4: object().__format__(format_spec) raises TypeError if format_spec is not an empty string.
直译
通过format_spec,将value转化为“格式化”的形式。format_spec的解析依赖于value参数的类型,无论如何,大多数内建类型通常使用一种标准格式化语法:Format Specification Mini-Language(格式化规范微语句)。
默认的format_spec是空字符串,通常与调用str(value)效果相同。
对format(value,