■ str 클래스의 format 메소드에서 . 기호를 사용해 소수점 자리수를 설정하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
print("{0:.1f}".format(4 / 3)) print("{0:.2f}".format(4 / 3)) print("{0:.3f}".format(4 / 3)) print("{0:.4f}".format(4 / 3)) print("{0:.5f}".format(4 / 3)) """ 1.3 1.33 1.333 1.3333 1.33333 """ |