ee.Number.format

printf 스타일 형식을 사용하여 숫자를 문자열로 변환합니다.

사용반환 값
Number.format(pattern)문자열
인수유형세부정보
다음과 같은 경우: number숫자문자열로 변환할 숫자입니다.
pattern문자열, 기본값: '%s'printf 스타일 형식 문자열입니다. 예를 들어 '%.2f'는 '3.14'와 같이 형식이 지정된 숫자를 생성하고 '%05d'는 '00042'와 같이 형식이 지정된 숫자를 생성합니다. 형식 문자열은 다음 기준을 충족해야 합니다.
  1. 0개 이상의 접두사 문자입니다.
  2. '%'가 정확히 하나 있습니다.
  3. [#-+ 0,(.\d] 집합에 있는 0개 이상의 수정자 문자
  4. [sdoxXeEfgGaA] 집합에 정확히 하나의 변환 문자가 있습니다.
  5. 0개 이상의 접미사 문자입니다.
형식 문자열에 대한 자세한 내용은 https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Formatter.html을 참고하세요.

코드 편집기 (JavaScript)

print('Zero-fill to length of 3',
      ee.Number(1).format('%03d'));  // 001

print('Include 1 decimal place in 1.2347',
      ee.Number(1.23476).format('%.1f'));  // 1.2

print('Include 3 decimal places in 1.2347',
      ee.Number(1.23476).format('%.3f'));  // 1.235 (rounds up)

print('Scientific notation with 3 decimal places shown',
      ee.Number(123476).format('%.3e'));  // 1.235e+05 (rounds up)

print('Integer with 2 decimal places of precision',
      ee.Number(123476).format('%.2f'));  // 123476.00

Python 설정

Python API 및 geemap를 사용한 대화형 개발에 관한 자세한 내용은 Python 환경 페이지를 참고하세요.

import ee
import geemap.core as geemap

Colab (Python)

print('Zero-fill to length of 3:',
      ee.Number(1).format('%03d').getInfo())  # 001

print('Include 1 decimal place in 1.2347:',
      ee.Number(1.23476).format('%.1f').getInfo())  # 1.2

print('Include 3 decimal places in 1.2347:',
      ee.Number(1.23476).format('%.3f').getInfo())  # 1.235 (rounds up)

print('Scientific notation with 3 decimal places shown:',
      ee.Number(123476).format('%.3e').getInfo())  # 1.235e+05 (rounds up)

print('Integer with 2 decimal places of precision:',
      ee.Number(123476).format('%.2f').getInfo())  # 123476.00