假设我有
a = [['abcTable : [os : set1] [origin : tag1] [os_version : p7] [0000_id : 1234567890] [cust : 75sa] [model : what-ra-ffff] [manufacturer : what] '],
['abcTable : [os : set1] [origin : tag2] [os_version : p8] [0000_id : unknown] [cust : 75sa] [model : tt_xy2U] [manufacturer : what] '],
['abcTable : [os : set1] [origin : tag1] [os_version : p7] [0000_id : 1234567890] [cust : 75sa] [model : what-ra-ffff] [manufacturer : what] '],
['abcTable : [os : set1] [origin : tag2] [os_version : p8] [0000_id : unknown] [cust : 75sa] [model : tt_xy2U] [manufacturer : what] ']]
请注意,a_0
和a_2
是等效的,而a_1
和a_3
是等效的。我该如何返回相同的列表,但删除重复的列表?
我已经尝试了枚举和列表理解的所有内容,但都没有成功。我认为是因为它是列表中的列表。
答案 0 :(得分:1)
如果您只想删除重复项,则可以使用set()
并转换回list
:
list(set(i[0] for i in a))
返回:
['abcTable : [os : set1] [origin : tag1] [os_version : p7] [0000_id : 1234567890] [cust : 75sa] [model : what-ra-ffff] [manufacturer : what] ',
'abcTable : [os : set1] [origin : tag2] [os_version : p8] [0000_id : unknown] [cust : 75sa] [model : tt_xy2U] [manufacturer : what] ']