去除数组中的相同元素

 python: 利用set

Python 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a=[1,2,3,4,5,3,2,1]
>>> a
[1, 2, 3, 4, 5, 3, 2, 1]
>>> set(a)
{1, 2, 3, 4, 5}
>>>



matlab: 使用unique(A)返回由A中的不重复元素构成的列表,相当于列表转集合。

发布了234 篇原创文章 · 获赞 61 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/weixin_42528089/article/details/103986371
今日推荐