##################集合######################## # l=['a','b',1,'a','a'] # print(list(set(l))) #集合转化列表 # stus_linux={'alex','egon','张全蛋','李铁蛋','oldboy'} # stus_python={'李二丫','wxx','liudehua','alex','egon'} #即报名Linux又报名Python的学生:交集 # print(stus_linux & stus_python) # print(stus_linux.intersection(stus_python)) #所有的学生:并集 # print(stus_linux | stus_python) # | 或 # print(stus_linux.union(stus_python)) #只报名Linux 没报Python 差集 # print(stus_linux - stus_python) # print(stus_linux.difference(stus_python)) #没有同时报名两门课程的学生姓名:交差补集 #print(stus_linux ^ stus_python) #print(stus_linux.symmetric_difference(stus_python)) # s1.isdisjoint() #如果两个集合没有交集 返回True # s1={1,2,3} # s2={4,5,6} # print(s1.isdisjoint(s2)) #循环取值 # s1={1,'a','b','c','d'} # for item in s1: # print(item)