轻轻的 发表于 2017-4-25 10:35:29

python 去掉重复行

  


#!/usr/bin/env python
import sys;
def usage():
print("%s <src_file> <dst_file>" %sys.argv);
if "__main__" == __name__:
if len(sys.argv) != 3:
usage();
sys.exit(1);
#read file
hFileSrc = open(sys.argv, 'r');
strText = hFileSrc.read();
hFileSrc.close();
#operate
strText = strText.replace('\r', '');
strText = strText.replace('\n\n', '\n');
#write file
hFileDst = open(sys.argv, "w");
hFileDst.write(strText);
hFileDst.close();
print("fix succ!");
 
页: [1]
查看完整版本: python 去掉重复行