🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] set,list,tuple之间的互换 ~~~ In [1]: a = set() In [2]: b=[1,2,3,4,12,3,1,2] In [3]: c = set(b) In [5]: c Out[5]: {1, 2, 3, 4, 12} ~~~ ~~~ In [6]: d=list(c) In [7]: In [7]: d Out[7]: [1, 2, 3, 4, 12] ~~~ ~~~ In [8]: e= tuple(d) In [9]: e Out[9]: (1, 2, 3, 4, 12) ~~~ ~~~ In [10]: f = list(e) In [11]: f Out[11]: [1, 2, 3, 4, 12] ~~~ ~~~ In [12]: g= set(e) In [13]: g Out[13]: {1, 2, 3, 4, 12} ~~~ 使用set,可以快速的完成对list中的元素去重复的功能