python 去掉数组中重复数据

admin 2014年5月29日01:04:15Python评论2,055 次浏览阅读模式

参考代码:

def unique(old_list):
    newList = []
    for x in old_list:
        if x not in newList :
            newList.append(x)
    return newList

自己举例:

array = ['22','11','11','33','44',(1,2),(2,3),(2,3),(3,4)]

arrayNew =[]

i = len(array)-1

for array[i] in array:

    if array[i] not in arrayNew:

        arrayNew.append(array[i])

        i=-1

print(arrayNew)

python 去掉数组中重复数据

相关文章
weinxin
我的微信
微信扫一扫
admin
  • 本文由 发表于 2014年5月29日01:04:15
  • 转载请务必保留本文链接:https://anyun.org/a/jishuguanzhu/bianchengchalou/python/2014/0529/1459.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: