[Tutor] Regex parsing and writing to file
jonvspython at gmail.com
Thu Oct 18 14:05:36 CEST 2007
I was not trying to get any output. I was trying to modify a source file in
place, I just want to replace file content text automatically. So I tried
first from python shell in linux. This is what I did:
[jon at pc-600713 aut]$ python
Python 2.4.3 (#1, Oct 23 2006, 14:19:47)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fileinput
>>> import re
>>> for line in fileinput.input("ets.AUT1",inplace=1):
But for an entry like the following in file "ets.AUT1":
This is what I got "ets.AUT1" content like this one:
' TRANS (EvtTout,ETSL8)\r\n'
The file I got as a result won't work. I just wan't the pattern replaced.
Do you know how could I do it?
Thanks again, Jon.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor