python之简单排序文本文件

import sys
import platform
import os
from subprocess import *


if len(sys.argv) != 2:
    print("arg error, " + sys.argv[0] + " input_file");
    exit(1)
input_file = sys.argv[1];

fp = open(input_file,"r+");
linesText = fp.readlines();
linesText.sort();
for line in linesText:
    print(line);
fp.seek(0)
fp.writelines(linesText)
fp.close();

print("finish");

你可能感兴趣的:(python)