【发布时间】:2018-08-06 15:03:24
【问题描述】:
我有一本字典,其中的键是元组。我正在寻找一个理解列表来分解列表中的元组
dicto={(1,2):1, (3,4):1, (5,6):3}
expected outcome: [1,2,3,4,5,6] (order doesnt matter)
到目前为止,我想出的最好的是:
[x for x, y in dicto.keys()] ### [x, y for x, y in dicto.keys()] doesnt work :-(
有没有一种优雅而优雅的方式可以在一行中实现这一点?
谢谢
【问题讨论】:
标签: python dictionary tuples