python 按多维列表中的某一个元素位进行排序
import os,re
top = os.popen("tasklist")
process_list = []
split_r = r"\s+"
memory_topTen = []
for key,item in enumerate(top):
item = str(item).rstrip("\n")
if key not in [0,1,2]:
result = re.split(split_r,item)
if len(result)== 6:
memory_topTen.append(result)
# print(memory_topTen)
# 获取列表第5个元素
def takeSecond(elem):
return elem[4]
memory_topTen.sort(key= takeSecond,reverse=True)
memory_topTen = memory_topTen[0:10]
for item in memory_topTen:
print(item)
技术改变一切