公告:所有在 
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。如果您在 2025 年 9 月 26 日之前未完成验证,您的访问权限可能会被暂停。
  
        
 
       
     
  
  
  
    
  
  
  
    
      ee.Number.format
    
    
      
    
    
      
      使用集合让一切井井有条
    
    
      
      根据您的偏好保存内容并对其进行分类。
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
    
  
  
使用 printf 样式格式将数字转换为字符串。
| 用法 | 返回 | 
|---|
| Number.format(pattern) | 字符串 | 
| 参数 | 类型 | 详细信息 | 
|---|
| 此: number | 数字 | 要转换为字符串的数字。 | 
| pattern | 字符串,默认值:“%s” | printf 样式的格式字符串。例如,“%.2f”会生成格式为“3.14”的数字,“%05d”会生成格式为“00042”的数字。格式字符串必须满足以下条件:   如需详细了解格式字符串,请参阅 https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Formatter.html零个或多个前缀字符。一个“%”。一组修饰符字符(零个或多个),属于 [#-+ 0,(.\d]。集合 [sdoxXeEfgGaA] 中仅包含一个转换字符。零个或多个后缀字符。 | 
  
  
  示例
  
    
  
  
    
    
  
  
  
  
    
    
    
      代码编辑器 (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)
    
    
  display('Zero-fill to length of 3:',
        ee.Number(1).format('%03d'))  # 001
display('Include 1 decimal place in 1.2347:',
        ee.Number(1.23476).format('%.1f'))  # 1.2
display('Include 3 decimal places in 1.2347:',
        ee.Number(1.23476).format('%.3f'))  # 1.235 (rounds up)
display('Scientific notation with 3 decimal places shown:',
        ee.Number(123476).format('%.3e'))  # 1.235e+05 (rounds up)
display('Integer with 2 decimal places of precision:',
        ee.Number(123476).format('%.2f'))  # 123476.00
  
  
  
  
  
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
  最后更新时间 (UTC):2025-10-30。
  
  
  
    
      [null,null,["最后更新时间 (UTC):2025-10-30。"],[],[]]