#!/usr/bin/env python
# coding : utf8
import re
import os,sys
#import fileinput
# read text
f = open(sys.argv[1],'rb')
text = f.readlines()
f.close()
c = []
for i in text:
  # match Chinese
  Char = re.findall("[^ -~]",i)
  Char = ''.join(Char).strip().split()
  for j in Char:
    c.append(j)
if len(c) == 0:
  sys.exit("Not found...")
else:
  # del repeat
  Char = list(set(c))
  for c in Char:  
    # replace Chinese
    cmd = """ sed -i "s/%s/\'%s\'/g" %s """%(c,c,sys.argv[1])
    print cmd
    os.system(cmd)

 

posted on 2017-11-21 14:02  杜先生的博客  阅读(464)  评论(0编辑  收藏  举报