有人能告诉我这件事吗
我有一份字典清单:
[{'overall': 5.0,
'vote': 'overall',
'reviewerID': 'AAP7PPBU72QFM'},
{'overall': 3.0,
'vote': '5',
'reviewerID': 'A2E168DTVGE6SV'},
...]
如何将“总体”和“投票”项转换为整数,同时将所有无效数字设置为0
更清楚地说,所需的输出是:
[{'overall': 5,
'vote': 0,
'reviewerID': 'AAP7PPBU72QFM'},
{'overall': 3,
'vote': 5,
'reviewerID': 'A2E168DTVGE6SV'},
...]
非常感谢
另一个解决方案很棒,这是另一个可读性解决方案:
对输入数据的测试表明此解决方案有效
给出输出:
shorly我希望它能为您工作,但与函数一起使用会更好
相关问题 更多 >
编程相关推荐