ee.Dictionary.contains

如果字典包含指定鍵,則傳回 true。

用量傳回
Dictionary.contains(key)布林值
引數類型詳細資料
這個:dictionary字典
key字串

範例

程式碼編輯器 (JavaScript)

// A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
var dict = ee.Dictionary({
  B1: 182,
  B2: 219,
  B3: 443
});

print('Dictionary contains key "B1"?', dict.contains('B1'));
print('Dictionary contains key "Band_1"?', dict.contains('Band_1'));

Python 設定

請參閱 Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

import ee
import geemap.core as geemap

Colab (Python)

# A dictionary (e.g. results of ee.Image.reduceRegion of an S2 image).
dic = ee.Dictionary({
    'B1': 182,
    'B2': 219,
    'B3': 443
})

print('Dictionary contains key "B1"?:', dic.contains('B1').getInfo())
print('Dictionary contains key "Band_1"?:', dic.contains('Band_1').getInfo())