跳转到内容

User: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()