如果我有一组数:
locSet = [(62.5, 121.0), (62.50000762939453, 121.00001525878906), (63.0, 121.0),(63.000003814697266, 121.00001525878906), (144.0, 41.5)]
我想把它们分组,公差范围是+/-3。在
^{pr2}$它回来了
[(62.5, 121.0), (144.0, 41.5)]
我见过Identify groups of continuous numbers in a list,但那是连续整数。在
如果我理解得很好的话,您正在搜索的元组的值在绝对量上的差异在容差范围内:[0,1,2,3]
假设这样,我的解决方案返回一个列表列表,其中每个内部列表都包含满足条件的元组。在
这里有两个使用示例:
^{pr2}$我希望能有所帮助。在
相关问题 更多 >
编程相关推荐