回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我有一句话:</p>
<pre><code>{'children': [{'children': [{'criteria': ['United Kingdom'],
'name': ['3'],
'prediction': ['0.256'],
'weights': ['604']},
{'criteria': ['United States'],
'name': ['4'],
'prediction': ['0.231'],
'weights': ['5316']}],
'criteria': ['United Kingdom United States'],
'name': ['2'],
'prediction': ['0.233'],
'variableNames': ['Country name'],
'weights': ['5920']},
{'children': [{'criteria': [' Brazil Canada'],
'name': ['6'],
'prediction': ['0.153'],
'weights': ['10029']},
{'criteria': ['France Germany Spain Turkey'],
'name': ['7'],
'prediction': ['0.053'],
'weights': ['1335']}],
'criteria': [' Brazil Canada France Germany Spain Turkey'],
'name': ['5'],
'prediction': ['0.141'],
'variableNames': ['Country name'],
'weights': ['11364']}],
'criteria': ['l 1'],
'name': ['1'],
'prediction': ['0.173'],
'variableNames': ['Country name'],
'weights': ['17284']}
</code></pre>
<p>我需要找到两个预测和权重的最大值和最小值,这两个值都是字符类型,所以我需要两者都将它们转换为Float/int,然后找到它们的max/min值,同时遍历所有键/值。在</p>
<p>通过使用一些previs很好的问题,我发现如果int的值有效:</p>
^{pr2}$
<p>这和我把值转换成int/float差不多:</p>
<pre><code>for body in test:
test[body]['prediction'] = float(test[body]['prediction'])
test[body]['weights'] = int(test[body]['weights'])
</code></pre>
<p>这又抛出了一个类似的错误。在</p>