上代码:
from heapq import heappush,heappop from collections import OrderedDict def toTreeMap(paramMap): "将paramMap转换为java中的treeMap形式.将map的keys变为heapq.创建有序字典." keys=paramMap.keys() heap=[] for item in keys: heappush(heap,item) sort=[] while heap: sort.append(heappop(heap)) resMap=OrderedDict() for key in sort: resMap[key]=paramMap.get(key) return resMap
时间: 2024-10-17 08:59:02