Python Set update() 方法

Python 3 教程 · 2019-02-06 21:42:22

描述

update() 方法用于修改当前集合,可以添加新的元素或集合到当前集合中,如果添加的元素在集合中已存在,则该元素只会出现一次,重复的会忽略。

语法

update() 方法语法:

set.update(set)

参数

  • set -- 必需,可以是元素或集合
  • 返回值

    无。

    实例

    合并两个集合,重复元素只会出现一次:

    实例 1

    x = {"apple", "banana", "cherry"} y = {"google", "codercto", "apple"} x.update(y) print(x)

    输出结果为:

    {'banana', 'apple', 'google', 'codercto', 'cherry'}
    

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

ActionScript 3.0 Cookbook

ActionScript 3.0 Cookbook

Joey Lott、Darron Schall、Keith Peters / Adobe Dev Library / 2006-10-11 / GBP 28.50

Well before Ajax and Microsoft's Windows Presentation Foundation hit the scene, Macromedia offered the first method for building web pages with the responsiveness and functionality of desktop programs......一起来看看 《ActionScript 3.0 Cookbook》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具