상세 컨텐츠

본문 제목

format

파이썬

by somiyuralove 2023. 4. 12. 21:44

본문

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 

 

Built-in Functions

The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order.,,,, Built-in Functions,,, A, abs(), aiter(), all(), a...

docs.python.org

https://www.w3schools.com/python/ref_string_format.asp

'파이썬' 카테고리의 다른 글

파이썬 클래스 개념  (0) 2023.04.17
파이썬 detetime 모듈 개념  (0) 2023.04.16
파이썬 모듈의 개념  (0) 2023.04.14
파이썬 상속 개념  (0) 2023.04.14

관련글 더보기

댓글 영역