小编use*_*919的帖子

在元组列表中使用bisect?

我试图弄清楚如何在元组列表中使用bisect

[(3, 1), (2, 2), (5, 6)]
Run Code Online (Sandbox Code Playgroud)

如何根据每个元组中的[1]将该列表一分为二?

list_dict [(69, 8), (70, 8), ((65, 67), 6)]
tup1,tup2 (69, 8) (70, 8)
list_dict [((65, 67), 6)]
fst, snd ((65, 67),) (6,)
Run Code Online (Sandbox Code Playgroud)

我正在插入二等分

idx = bisect.bisect(fst, tup1[1]+tup2[1])
Run Code Online (Sandbox Code Playgroud)

哪能给我 unorderable types: int() < tuple()

python python-3.3

11
推荐指数
3
解决办法
5792
查看次数

标签 统计

python ×1

python-3.3 ×1