21.03.2015 г.

Direct change file with python use with use fileinput

1
2
3
4
5
6
7
8
import re
import fileinput
fname = "123.txt"
#( file has line: Ala bala 123)

for line in fileinput.FileInput(fname, inplace=1):
     line = re.sub(r'Ala bala \d{3}', "New Wine", line)
     print line

Няма коментари :

Публикуване на коментар