Sunday Blog

人生是一场刻意练习

Python Set 集合

Python Set

集合Set Python中,它是可变的、无序的、不重复的元素的集合 初始化 set( ) set(iterable) s1=set( ) s2=set(range(5)) s3=set([1,2,3]) s4=set('abcd') 注意: s5={ } #是字典不是集合 s6={1,2,3} s7={1,(1,)} s8=(1,(1,),[1]} #报错 元素性质 去重:在