我有兩個元組a = (('1',), ('2',), ('3',),)
和b = (('1',), ('3',),)
。我需要得到結果爲(('2',),)
,因爲2是存在於a
而不是b
中的元素。在Python中找到兩個元組中的缺失元素
我提到這個Find intersection of two lists?和Is there a way to get the difference and intersection of tuples or lists in Python?獲得一個想法,但這些是爲列表而不是元組。我無法爲元組使用intersection()。
有沒有辦法可以在python元組中獲得a-b
?