小编0x0*_*01h的帖子

按元组第一个值排列的唯一元组列表

如何以最 Pythonic 的方式根据元组的第一个值创建唯一的元组列表?

例子:

list_of_tuples = [('a', 1), ('a', 2), ('b', 3)]

# Apply here magical Pythonic one liner.

print(list_of_tuples)

[('a', 1), ('b', 3)]
Run Code Online (Sandbox Code Playgroud)

python tuples list unique python-3.x

5
推荐指数
1
解决办法
1599
查看次数

标签 统计

list ×1

python ×1

python-3.x ×1

tuples ×1

unique ×1