<p>如果您使用<code>numpy</code>,它会更容易一些</p>
<pre><code>import numpy as np
orig = [({'x': 28.346, 'y': 19}, 'Text0'),
({'x': 109.726, 'y': 19}, 'Text1'),
({'x': 147.776, 'y': 19}, 'Text2'),
({'x': 153.606, 'y': 24}, 'Text3'),
({'x': 452.788, 'y': 24}, 'Text4'),
({'x': 504.168, 'y': 34}, 'Text5'),
({'x': 527.768, 'y': 34}, 'Text6'),
({'x': 533.598, 'y': 45}, 'Text7'),
({'x': 64.291, 'y': 55}, 'Text8'),
({'x': 98.623, 'y': 55}, 'Text9')]
input_array = np.array([val[0]['y'] for val in orig])
out_array = [np.where(input_array == element)[0].tolist() for element in np.unique(input_array)]
res = [[orig[i] for i in ind_arr] for ind_arr in out_array]
print(res)
</code></pre>
<p>输出:</p>
<pre><code>[[({'x': 28.346, 'y': 19}, 'Text0'),
({'x': 109.726, 'y': 19}, 'Text1'),
({'x': 147.776, 'y': 19}, 'Text2')],
[({'x': 153.606, 'y': 24}, 'Text3'),
({'x': 452.788, 'y': 24}, 'Text4')],
[({'x': 504.168, 'y': 34}, 'Text5'),
({'x': 527.768, 'y': 34}, 'Text6')],
[({'x': 533.598, 'y': 45}, 'Text7')],
[({'x': 64.291, 'y': 55}, 'Text8'),
({'x': 98.623, 'y': 55}, 'Text9')]]
</code></pre>