久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如果它們完全相同,包括項目的順序,則從列表

Remove duplicate tuples from a list if they are exactly the same including order of items(如果它們完全相同,包括項目的順序,則從列表中刪除重復的元組)
本文介紹了如果它們完全相同,包括項目的順序,則從列表中刪除重復的元組的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我知道類似的問題已經(jīng)在 Stack Overflow 上被問過很多次了,但我需要從列表中刪除重復的元組,但不僅僅是它們的元素匹配,它們的元素必須按相同的順序排列.換句話說,(4,3,5)(3,4,5) 都將出現(xiàn)在輸出中,而如果兩者都有 (3,3,5)(3,3,5),只有一個會在輸出中.

I know questions similar to this have been asked many, many times on Stack Overflow, but I need to remove duplicate tuples from a list, but not just if their elements match up, their elements have to be in the same order. In other words, (4,3,5) and (3,4,5) would both be present in the output, while if there were both(3,3,5) and (3,3,5), only one would be in the output.

具體來說,我的代碼是:

Specifically, my code is:

import itertools

x = [1,1,1,2,2,2,3,3,3,4,4,5]
y = []

for x in itertools.combinations(x,3):
    y.append(x)
print(y)

其中的輸出很長.例如,在輸出中,應(yīng)該同時存在 (1,2,1)(1,1,2).但是應(yīng)該只有一個(1,2,2).

of which the output is quite lengthy. For example, in the output, there should be both (1,2,1) and (1,1,2). But there should only be one (1,2,2).

推薦答案

set 會解決這個問題:

set will take care of that:

>>> a = [(1,2,2), (2,2,1), (1,2,2), (4,3,5), (3,3,5), (3,3,5), (3,4,5)]
>>> set(a)
set([(1, 2, 2), (2, 2, 1), (3, 4, 5), (3, 3, 5), (4, 3, 5)])
>>> list(set(a))
[(1, 2, 2), (2, 2, 1), (3, 4, 5), (3, 3, 5), (4, 3, 5)]
>>>

set 將僅刪除 exact 個重復項.

set will remove only exact duplicates.

這篇關(guān)于如果它們完全相同,包括項目的順序,則從列表中刪除重復的元組的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 欧美成人精品激情在线观看 | 亚洲人久久 | 日日夜夜天天干 | 欧美一区二区黄 | 男人的天堂一级片 | 亚洲精品日韩一区二区电影 | 狠狠的干| 午夜爽爽爽男女免费观看影院 | 国产永久免费 | 国产三区在线观看视频 | 亚洲精品视频在线 | 久久国产视频网 | 精品一二三区在线观看 | 精品国产一区二区三区免费 | 黄色网页在线观看 | 女人精96xxx免费网站p | 成人h视频在线 | 九九在线视频 | 午夜视频在线播放 | 免费在线观看一区二区 | 台湾佬成人网 | 日韩av大片免费看 | 日韩成人国产 | 国产美女视频一区 | 激情五月婷婷 | 欧美一区二区三区免费在线观看 | 日韩在线精品视频 | 久久久久网站 | 中文字幕日韩欧美一区二区三区 | 久久综合九色综合欧美狠狠 | 91精品国产欧美一区二区成人 | 天天干天天色 | 91九色视频在线 | 91久久久久久久 | 色欧美片视频在线观看 | 男人午夜视频 | 久久精品国产免费 | av黄色片| 欧美一区二区三区视频 | 99精品国产一区二区三区 | 欧美日韩不卡合集视频 |