# Author:Yan
#集合无序,内容唯一
list_1 = {1,2,3,4,5,6,7,2}
list_2 = {1,0,3,8,6,6,22,2}
print(type(list_1))
#交集
print(list_1 & list_2)
#并集
print(list_1 | list_2)
#差集
print(list_1 - list_2)
#对称差集 出现在list1 或list2,但不会同时出现在二者中
print(list_1 ^ list_2)
#add
list_1.add('x') #add one
list_1.update('999','666') #add manny
#delete
list_1.remove('1')
#long
len(list_1)
#whether ---> bool
x in list_1
x not in list_1
list_1.issubset('x')
Python 学习 ----4(集合)
最新推荐文章于 2023-02-05 13:06:50 发布