Earth Engine 即將推出
非商業用途的配額級別,以便保護共用運算資源,並確保所有使用者都能享有穩固效能。所有非商業用途的專案都必須在
2026 年 4 月 27 日前選取配額級別,否則屆時會預設為「社群」級別。在
2026 年 4 月 27 日,所有專案 (無論選取級別的日期為何) 的級別配額都會生效。
瞭解詳情。
ee.Number.parse
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
將字串轉換為數字。
| 用量 | 傳回 |
|---|
ee.Number.parse(input, radix) | 數字 |
| 引數 | 類型 | 詳細資料 |
|---|
input | 字串 | 要轉換成數字的字串。 |
radix | 整數,預設值為 10 | 代表要轉換的基數系統。如果輸入內容不是整數,基數必須等於 10 或未指定。 |
範例
程式碼編輯器 (JavaScript)
print('Client-side string converted to ee.Number',
ee.Number.parse('10')); // 10
print('ee.String converted to ee.Number',
ee.Number.parse(ee.String('100'))); // 100
print('Ambiguous string object converted to ee.Number',
ee.Number.parse(ee.Feature(null, {id: '1000'}).get('id'))); // 1000
print('Ambiguous number object converted to ee.Number',
ee.Number.parse(ee.Feature(null, {id: 1000}).get('id'))); // 1000
print('Leading zeros are removed',
ee.Number.parse('0001')); // 1
print('Radix 16', ee.Number.parse('3E8', 16)); // 1000
Python 設定
請參閱
Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。
import ee
import geemap.core as geemap
Colab (Python)
display('Client-side string converted to ee.Number:',
ee.Number.parse('10')) # 10
display('ee.String converted to ee.Number:',
ee.Number.parse(ee.String('100'))) # 100
# 1000
display('Ambiguous string object converted to ee.Number:',
ee.Number.parse(ee.Feature(None, {'id': '1000'}).get('id')))
display('Leading zeros are removed:', ee.Number.parse('0001')) # 1
display('Radix 16:', ee.Number.parse('3E8', 16)) # 1000
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-10-30 (世界標準時間)。
[null,null,["上次更新時間:2025-10-30 (世界標準時間)。"],[],["`ee.Number.parse()` converts a string to a number. It accepts a string `input` and an optional `radix` (default 10), representing the base of the number system. If the input isn't an integer, radix must be 10 or unspecified. Leading zeros are removed during conversion. The examples show parsing client-side strings, `ee.String` objects, and ambiguous objects, both in JavaScript and Python. Base 16 conversions using radix are also shown.\n"]]