【发布时间】:2021-12-08 18:57:49
【问题描述】:
这是我的输入数据。
data = {323: [[639, 646]], 325: [[1491, 1507]], 332: [[639, 647], [823, 833], [1274, 1298]], 334: [[640, 646]], 335: [[822, 834]]}
我想删除值小于或等于10的子列表。
我的输出应该是这样的。
output_data = {323: [], 325:[[1491,1507]], 332:[[1274,1298]], 334:[], 335:[[822,834]]}
我怎样才能达到想要的输出?
【问题讨论】:
-
你能澄清一下上面的要求吗? “其值小于或等于 10” - 我注意到情况并非如此。
-
值是指列表子列表中的元素 (639,646)、(1491,1507)... 等等。
-
我认为条件是值差异小于或等于10。
-
是的,我也指那些。但是比如我不明白639是怎么小于等于10的。
-
我想计算这些元素的差异。如果差值
标签: python-3.x list dictionary list-comprehension dictionary-comprehension