The World Wide Web, restored to 800 pixels of glory.
GeezerVison is showing www.runoob.com — Python Set difference() 方法 | 菜鸟教程
Python 集合
difference() 方法用于返回集合的差集,即返回的集合元素包含在第一个集合中,但不包含在第二个集合(方法的参数)中。
difference() 方法语法:
set.difference(set)
返回一个新的集合。
返回一个集合,元素包含在集合 x ,但不在集合 y :
输出结果为:
{'cherry', 'banana'}
取消