Python013set_list_tuple

set 的简单应用以后会更复杂。。。。。。

set 集合

跟列表一样,但是它不重复

1
2
3
4
5
6
7
8
9
10
a = [11,22,33,44,55,11]

b = set(a)
# {11,22,33,44}
type(b)
# set


c = list(b)
# [33,11,44,22] 集合转成列表虽然去重但是是无序的

set list tuple相互可以转化

1
2
3
4
5
6
a = (11,22,33,44,55,11)
b = set(a)
# {11,22,33,44}

c = tuple(b)
# (11,22,33,44)