久久久久久久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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 久久99久久99精品免视看婷婷 | 亚洲精品日本 | 欧美黄视频 | 久久综合香蕉 | 男女羞羞视频免费看 | 性大毛片视频 | 亚洲视频一区在线 | 成人精品在线观看 | 欧美视频一区二区三区 | 日韩免费一区二区 | 在线视频成人 | 天堂一区二区三区 | 国产精品欧美一区二区三区不卡 | 色视频网站 | 秋霞电影一区二区 | 91麻豆精品国产91久久久资源速度 | 亚洲一区在线日韩在线深爱 | 国产午夜精品久久久 | 国际精品鲁一鲁一区二区小说 | 欧美激情在线一区二区三区 | 中文字幕在线观看 | 亚洲一区二区三区高清 | 欧美做暖暖视频 | 精品免费 | 伊人精品一区二区三区 | 久久国产综合 | av第一页 | 欧美精品日韩精品国产精品 | 亚洲精品一区久久久久久 | 四虎成人免费视频 | 福利国产 | 久久精品这里精品 | 黄色在线免费观看视频网站 | 欧洲一级黄 | 国产成人精品一区二区在线 | 国产不卡一区 | 99re视频在线观看 | 免费在线观看成人 | 日韩毛片网 | 日韩中文在线视频 | av二区三区 |