format(value, format_spec='')¶
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.
* refrence link
https://docs.python.org/3/library/functions.html?highlight=format#format
파이썬 클래스 개념 (0) | 2023.04.17 |
---|---|
파이썬 detetime 모듈 개념 (0) | 2023.04.16 |
파이썬 모듈의 개념 (0) | 2023.04.14 |
파이썬 상속 개념 (0) | 2023.04.14 |
댓글 영역