format() 메서드는 주어진 format_spec에 의해 제어되는 지정된 값의 형식화된 표현을 반환합니다.
format_spec에 의해 지정된 값의 형식화된 표현을 반환합니다.
# d, f, b는 타입입니다.
# integer
print(format(123, "d"))
# float
print(format(123.4567898, "f"))
# binary 포맷
print(format(12, "b"))
결과
123 123.456790 1100
© 2022 pinfo. All rights reserved.