1. 程式人生 > >python 實現txt檔案 按 value值排序從高到低

python 實現txt檔案 按 value值排序從高到低

with open('sort.txt','w+') as w:
     while True:
          sorted_lines=sorted(open('1.txt'), key=lambda s: s.split()[4],reverse=1)
          w.write("".join(sorted_lines))
          break