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
Web Standards Creativity
Andy Budd、Dan Rubin、Jeff Croft、Cameron Adams、Ethan Marcotte、Andy Clarke、Ian Lloyd、Mark Boulton、Rob Weychert、Simon Collison、Derek Featherstone / friends of ED / March 19, 2007 / $49.99
Book Description * Be inspired by 10 web design lessons from 10 of the world's best web designers * Get creative with cutting-edge XHTML, CSS, and DOM scripting techniques * Learn breathtakin......一起来看看 《Web Standards Creativity》 这本书的介绍吧!