开发者社区> 问答> 正文

python实现列表去重按照索引再次排序的方法是什么?

python实现列表去重按照索引再次排序的方法是什么?

展开
收起
cuicuicuic 2021-11-02 20:19:00 335 0
1 条回答
写回答
取消 提交回答
  • 按照索引再次排序

    @param Python对列表去重的4种方法

    @author 512笔记|512Pic.com

    orgList = [1,0,3,7,7,5]

    formatList = list(set(orgList))

    formatList.sort(key=orgList.index)

    print (formatList)

    End www_512pic_com

    结果:

    [1, 0, 3, 7, 5]

    End www_512pic_com

    2021-11-02 20:19:18
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载