开发者社区 问答 正文

python实现列表去重使用keys()的方法是什么?

python实现列表去重使用keys()的方法是什么?

展开
收起
真的很搞笑 2021-11-02 20:17:08 316 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • 使用keys()方法

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

    @author 512笔记|512Pic.com

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

    #list()方法是把字符串str或元组转成数组

    formatList = list({}.fromkeys(orgList).keys())

    print (formatList)

    End www_512pic_com

    结果:

    [0, 1, 3, 5, 7]

    End www_512pic_com

    2021-11-02 20:17:43 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论