(100 days, 2 hours, third day) Set collection

Set collection is a set of unordered and non-repeating elements. Basic functions include relationship testing and elimination of duplicate elements .

s={1,1,2,3,4,5,5,}
print(s)  #消除重复元素
print(1 in s) #测试功能
print(8 in s)

  

Sets also support comprehensions

a={x for x in 'abcdabcrabaabc' if x not in 'abc'}
print(a)

  

Guess you like

Origin blog.csdn.net/zhangxue1232/article/details/109334259