跳转到内容

用户:Wmrwiki/py

维基文库,自由的图书馆

感谢User:liangent提供的代码(python 2.5)

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
fn = sys.argv[1] if len(sys.argv) != 1 else raw_input('file')
fr = file(r'D:\users\wmr\Desktop\00.txt', 'r')
fw = file(r'D:\users\wmr\Desktop\00.txt' + '.out', 'w')
for l in fr:
 if u'◇' in l.decode('utf-8'):
  print >>fw, '888' + l.replace('\n', '') + '555'
 else:
  print >>fw, l.replace('\n', '')
fr.close()
fw.close()