互联网技术 / 互联网资讯 · 2024年4月2日

Python3集合内置add()方法的云计算开发

描述

Python3 add() 方法用于给集合添加元素,如果添加的元素在集合中已存在,则不执行任何操作。

语法

以下是 add() 方法的语法:

set.add(elMnt)

参数

elMnt — 必需,要添加的元素。

实例

以下展示了使用 add() 方法的实例:

云计算开发:Python3集合内置add()方法

已存在的元素,则不执行添加操作:

云计算开发:Python3集合内置add()方法
OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册