Python Set symmetric_difference_update() 方法

Python 3 教程 · 2019-02-06 21:14:48

描述

symmetric_difference_update() 方法移除当前集合中在另外一个指定集合相同的元素,并将另外一个指定集合中不同的元素插入到当前集合中。

语法

symmetric_difference_update() 方法语法:

set.symmetric_difference_update(set)

参数

  • set -- 要检测的集合

返回值

无。

实例

在原始集合 x 中移除与 y 集合中的重复元素,并将不重复的元素插入到集合 x 中:

实例 1

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

输出结果为:

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

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

查看所有标签

Design systems

Design systems

Not all design systems are equally effective. Some can generate coherent user experiences, others produce confusing patchwork designs. Some inspire teams to contribute to them, others are neglected. S......一起来看看 《Design systems》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

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

HTML 编码/解码

SHA 加密
SHA 加密

SHA 加密工具