我有一个由子列表组成的列表。我需要在子列表的特定位置找到最大的元素。我已经将主列表放在 for 循环中,所以我可以直接操作子列表。但是列表采用字符串类型,所以当我使用 Max 函数时它无法给我最大的数字。
each_entry :
[['10', '1', 'SELL', 'toaster_1', '10.00', '20'],
['12', '8', 'BID', 'toaster_1', '7.50'],
['13', '5', 'BID', 'toaster_1', '12.50'],
['17', '8', 'BID', 'toaster_1', '20.00']]
[['15', '8', 'SELL', 'tv_1', '250.00', '20'],
['18', '1', 'BID', 'tv_1', '150.00'],
['19', '3', 'BID', 'tv_1', '200.00'],
['21', '3', 'BID', 'tv_1', '300.00']]
for each_bid_item in dictlist:
for each_entry in each_bid_item:
initial_time = (each_entry[0][0])
max_time = (each_entry[0][5])
reserve_price = (each_entry[0][4])
sell_item = (each_entry[0][3])
当我打字时
print(max(each_entry[0][4]))
Output :
1
5
简而言之,我需要找到第一个和第二个子列表的最高出价。
12345678_0001
相关分类