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

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

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

問題描述

我知道類似的問題已經在 Stack Overflow 上被問過很多次了,但我需要從列表中刪除重復的元組,但不僅僅是它們的元素匹配,它們的元素必須按相同的順序排列.換句話說,(4,3,5)(3,4,5) 都將出現在輸出中,而如果兩者都有 (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)

其中的輸出很長.例如,在輸出中,應該同時存在 (1,2,1)(1,1,2).但是應該只有一個(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.

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

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

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 91久久国产综合久久 | 国产一区二区精品在线观看 | 国产精品成人久久久久a级 久久蜜桃av一区二区天堂 | 91精品国产一区二区三区 | 在线一区二区三区 | 日本精品裸体写真集在线观看 | 国产伦精品一区二区三区在线 | 欧美在线视频不卡 | 欧美一区二区精品 | 欧美成人影院 | 成人性生交大片免费看中文带字幕 | 欧美色a v| 国产成人精品一区二区三区视频 | 久久在看 | 久久精品色欧美aⅴ一区二区 | 一道本在线 | 久久精品99| 日韩av.com | 精精国产xxxx视频在线播放7 | 第一av| 中文字幕综合 | 国产精品视频在线播放 | 国产精品一区二区三区久久久 | 理论片免费在线观看 | 日韩一区二区在线视频 | 国产高清视频一区 | 超级乱淫av片免费播放 | 美女黄视频网站 | h片在线观看网站 | 国产精品亚洲成在人线 | h片在线观看免费 | cao视频 | 99视频| 亚洲女人天堂成人av在线 | 9191av| 日本精品一区二区三区在线观看 | 麻豆久久久久久久久久 | 日韩在线不卡视频 | 久久精品免费观看 | 国产电影一区二区在线观看 | 一级免费看|