def subMenu_5():
# read file into array of lines
lines = open("database").readlines()
# sort those lines using a lambda
lines.sort(key = lambda line : line.split("\t")[3])
clientList = []
dataQuantify = 0
database = open('database','r')
i = 1
while (i == 1):
if (database.readline() == ''):
i = 0
else:
dataQuantify = dataQuantify + 1
database.close()
sortList = open("sortList","w")
for i in range (3):
sortList.write(lines[i])
sortList.close()
print "[Código] [Nome] [Quant. Prod. Comprados] [Valor Gasto] [Descontos] \n"
sortList = open('sortList','r')
i = 0
while (i < dataQuantify):
clientList.append(sortList.readline())
print clientList[i]
i = i + 1
database.close()
raw_input("Precione 'ENTER' para voltar ao menu principal... ")
return
# read file into array of lines
lines = open("data.txt").readlines()
# sort those lines using a lambda
lines.sort(key = lambda line : line.split("\t")[2])
这工作!非常感谢
是的,当然有可能。例如:
lambda从要用作排序键的行中挤出
SPENT
列相关问题 更多 >
编程相关推荐