# -*- coding: utf-8 -*- import heapq nums = [1, 8, 2, 23, 7, -4, 18, 23, 24, 37, 2] # 最大的3个数的索引 max_num_index_list = map(nums.index, heapq.nlargest(3, nums)) # 最小的3个数的索引 min_num_index_list = map(nums.index, heapq.nsmallest(3, nums)) print(list(max_nu…