公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ee.List.add
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
将元素附加到列表末尾。
参数 | 类型 | 详细信息 |
---|
此:list | 列表 | |
element | 对象 | |
示例
代码编辑器 (JavaScript)
print(ee.List([]).add('b')); // ["b"]
print(ee.List(['a']).add('b')); // ["a","b"]
print(ee.List(['a']).add(ee.String('b'))); // ["a","b"]
print(ee.List(['a']).add(1)); // ["a",1]
print(ee.List(['a']).add(ee.Number(1))); // ["a",1]
print(ee.List(['a']).add(true)); // ["a",true]
print(ee.List(['a']).add([])); // ["a",[]]
print(ee.List(['a']).add(ee.List([]))); // ["a",[]]
print(ee.List(['a']).add(['b'])); // ["a",["b"]]
print(ee.List(['a']).add(ee.List(['b']))); // ["a",["b"]]
print(ee.List(['a']).add(ee.Dictionary())); // ["a",{}]
print(ee.List(['a']).add(ee.Dictionary({b: 'c'}))); // ["a",{"b":"c"}]
// 0: a
// 1: Image (1 band)
print(ee.List(['a']).add(ee.Image.constant(1)));
// ["a",{"type":"ImageCollection","bands":[]}]
print(ee.List(['a']).add(ee.ImageCollection([])));
Python 设置
如需了解 Python API 和如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
Colab (Python)
print(ee.List([]).add('b').getInfo()) # ['b']
print(ee.List(['a']).add('b').getInfo()) # ['a', 'b']
print(ee.List(['a']).add(ee.String('b')).getInfo()) # ['a', 'b']
print(ee.List(['a']).add(1).getInfo()) # ['a', 1]
print(ee.List(['a']).add(ee.Number(1)).getInfo()) # ['a', 1]
print(ee.List(['a']).add(True).getInfo()) # ['a', True]
print(ee.List(['a']).add([]).getInfo()) # ['a', []]
print(ee.List(['a']).add(ee.List([])).getInfo()) # ['a', []]
print(ee.List(['a']).add(['b']).getInfo()) # ['a', ['b']]
print(ee.List(['a']).add(ee.List(['b'])).getInfo()) # ['a', ['b']]
print(ee.List(['a']).add(ee.Dictionary()).getInfo()) # ['a', {}]
# ['a', {'b': 'c'}]
print(ee.List(['a']).add(ee.Dictionary({'b': 'c'})).getInfo())
# 0: a
# 1: Image (1 band)
print(ee.List(['a']).add(ee.Image.constant(1)).getInfo())
# ["a", {"type":"ImageCollection", "bands":[]}]
print(ee.List(['a']).add(ee.ImageCollection([])).getInfo())
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003e\u003ccode\u003eList.add()\u003c/code\u003e appends an element to the end of a list and returns the modified list.\u003c/p\u003e\n"],["\u003cp\u003eThe method accepts any object as the element to be added.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eList.add()\u003c/code\u003e can be chained with other list methods for more complex operations.\u003c/p\u003e\n"],["\u003cp\u003eThe original list is not modified; a new list with the added element is returned.\u003c/p\u003e\n"]]],["The `List.add(element)` function appends an element to the end of a list. It takes an object as an argument (`element`), which can be any data type. The function modifies the list by adding the provided element at the end. It returns the modified list. The examples show different elements added to a list, including strings, numbers, booleans, empty lists, and even more complex data structures like dictionaries, images, and image collections.\n"],null,["# ee.List.add\n\nAppends the element to the end of list.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|---------------------|---------|\n| List.add`(element)` | List |\n\n| Argument | Type | Details |\n|--------------|--------|---------|\n| this: `list` | List | |\n| `element` | Object | |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nprint(ee.List([]).add('b')); // [\"b\"]\nprint(ee.List(['a']).add('b')); // [\"a\",\"b\"]\nprint(ee.List(['a']).add(ee.String('b'))); // [\"a\",\"b\"]\n\nprint(ee.List(['a']).add(1)); // [\"a\",1]\nprint(ee.List(['a']).add(ee.Number(1))); // [\"a\",1]\n\nprint(ee.List(['a']).add(true)); // [\"a\",true]\n\nprint(ee.List(['a']).add([])); // [\"a\",[]]\nprint(ee.List(['a']).add(ee.List([]))); // [\"a\",[]]\nprint(ee.List(['a']).add(['b'])); // [\"a\",[\"b\"]]\nprint(ee.List(['a']).add(ee.List(['b']))); // [\"a\",[\"b\"]]\n\nprint(ee.List(['a']).add(ee.Dictionary())); // [\"a\",{}]\nprint(ee.List(['a']).add(ee.Dictionary({b: 'c'}))); // [\"a\",{\"b\":\"c\"}]\n\n// 0: a\n// 1: Image (1 band)\nprint(ee.List(['a']).add(ee.Image.constant(1)));\n\n// [\"a\",{\"type\":\"ImageCollection\",\"bands\":[]}]\nprint(ee.List(['a']).add(ee.ImageCollection([])));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nprint(ee.List([]).add('b').getInfo()) # ['b']\nprint(ee.List(['a']).add('b').getInfo()) # ['a', 'b']\nprint(ee.List(['a']).add(ee.String('b')).getInfo()) # ['a', 'b']\n\nprint(ee.List(['a']).add(1).getInfo()) # ['a', 1]\nprint(ee.List(['a']).add(ee.Number(1)).getInfo()) # ['a', 1]\n\nprint(ee.List(['a']).add(True).getInfo()) # ['a', True]\n\nprint(ee.List(['a']).add([]).getInfo()) # ['a', []]\nprint(ee.List(['a']).add(ee.List([])).getInfo()) # ['a', []]\nprint(ee.List(['a']).add(['b']).getInfo()) # ['a', ['b']]\nprint(ee.List(['a']).add(ee.List(['b'])).getInfo()) # ['a', ['b']]\n\nprint(ee.List(['a']).add(ee.Dictionary()).getInfo()) # ['a', {}]\n\n# ['a', {'b': 'c'}]\nprint(ee.List(['a']).add(ee.Dictionary({'b': 'c'})).getInfo())\n\n# 0: a\n# 1: Image (1 band)\nprint(ee.List(['a']).add(ee.Image.constant(1)).getInfo())\n\n# [\"a\", {\"type\":\"ImageCollection\", \"bands\":[]}]\nprint(ee.List(['a']).add(ee.ImageCollection([])).getInfo())\n```"]]