pythons=['alex','egon','yuanhao','wupeiqi','gangdan','biubiu']
linuxs=['wupeiqi','oldboy','gangdan']
#求二者共同的部分:求即报名python又报名linux的学生
# l=[]
# for item in pythons:
# if item in linuxs:
# l.append(item)
# print(l)
#求只报名python,没有报名linux的学生
# l=[]
# for item in pythons:
# if item not in linuxs:
# l.append(item)
# print(l)
# 知识点回顾
# 可变类型是不可hash类型
# 不可变类型是可hash类型
# d={[1,2,3]:'egon',}
#定义集合
#集合:可以包含多个元素,用逗号分割,
#集合的元素遵循三个原则:
#1:每个元素必须是不可变类型
#2:没有重复的元素
#3:无序
# s={1,2,2,'eaaa',(1,2,3)} #s=set({1, 2, (1, 2, 3), 'eaaa'})
# print(s,type(s))
#优先掌握
# in 和 not in #成员检测操作符
# pythons={'alex','egon','yuanhao','wupeiqi','gangdan','biubiu'}
#
# print('egon' in pythons)
#
# |并集:老男孩所以报名的学生名字集合
pythons={'alex','egon','yuanhao','wupeiqi','gangdan','biubiu'}
linuxs={'wupeiqi','oldboy','gangdan'}
#
# s=pythons | linuxs
# print(s)
# print(pythons.union(linuxs))
# &交集:求二者共同的部分:求即报名python又报名linux的学生
# pythons={'alex','egon','yuanhao','wupeiqi','gangdan','biubiu'}
# linuxs={'wupeiqi','oldboy','gangdan'}
# #
# s=pythons & linuxs
# print(s)
#
# print(pythons.intersection(linuxs))
# print(linuxs.intersection(pythons))
#
# -差集:求只报名python,没有报名linux的学生
# pythons={'alex','egon','yuanhao','wupeiqi','gangdan','biubiu'}
# linuxs={'wupeiqi','oldboy','gangdan'}
# print(pythons - linuxs)
# print(pythons.difference(linuxs))
#
# print(linuxs - pythons)
# print(linuxs.difference(pythons))
# #
# ^对称差集: 没有同时报名python和linux课程的学生名字集合
# pythons={'alex','egon','yuanhao','wupeiqi','gangdan','biubiu'}
# linuxs={'wupeiqi','oldboy','gangdan'}
# print(pythons ^ linuxs)
#
# print(pythons.symmetric_difference(linuxs))
# print(linuxs.symmetric_difference(pythons))
# ==
set1={1,2,3}
set2={1,2,3}
# print(set1 == set2)
# >,>= ,<,<= 父集,子集
set1={1,2,3,4,5}
set2={1,2,3,4}
# print(set1 >= set2)
# print(set1.issuperset(set2))
#
# print(set2 <= set1)
# print(set2.issubset(set1))
#掌握
linuxs={'wupeiqi','oldboy','gangdan'}
# linuxs.add('asb') #set类型的集合是可变类型
# linuxs.add([1,2,3]) #报错,只能添加不可变类型
# print(linuxs)
# res=linuxs.pop() #不用指定参数,随机删除,并且会有返回值
# print(res)
# res=linuxs.remove('oldboy') #指定元素删除,元素不存在则报错,单纯的删除,没有返回值,
# # print(linuxs)
# print(res)
#
# res= linuxs.discard('oldboy1111111') #指定元素删除,元素不存在不报错,单纯的删除,没有返回值,
# # print(linuxs)
# print(res)
#了解
linuxs={'wupeiqi','oldboy','gangdan'}
new_set={'wupeiqi','alex_SB'}
# linuxs.update(new_set)
# print(linuxs)
# new_set.update(linuxs)
# print(new_set)
# linuxs.clear()
# linuxs.copy()
set1={1,2,3}
set2={4,1,2}
# print(set1 - set2)
# print(set1.difference(set2))
# set1=set1-set2
# print(set1)
# set1=set1.difference(set2)
# print(set1)
# set1.difference_update(set2)
# print(set1)
# msg='hello'
# msg=[1,2,'egon','egon']
# msg=[1,2,'egon','egon',[1,2],[1,2]]
# s=set(msg) #{1,2,'egon','egon',[1,2],[1,2]}
# print(s)
#for
# pythons={'alex','egon','yuanhao','wupeiqi','gangdan','biubiu'}
# for item in pythons:
# print(item)
#解压
#
# a,*_={'alex','egon','yuanhao','wupeiqi','gangdan','biubiu'}
# print(a)
#in:字符串,列表,元组,字典,集合
#for:字符串,列表,元组,字典,集合
#解压:字符串,列表,元组,字典,集合