Python: How to use the re module?
In Python if I want to use the re module with a file how would I do that? Open the file and read in with readlines is what I'm imagining:
Code:
for line in open('file1.csv').readlines(): And what would be the Python equivalent of sed 's/cat/dog/g'? (I don't want to use sed or the OS module.) |
Maybe you are over thinking this.
Code:
for line in open('in.txt').readlines(): Quote:
Code:
for line in open('in.txt').readlines(): |
Thank you I ended up using:
Code:
g4 = open('workfile4', 'wb') To clean the file(s) up I used a lot of: Code:
scriptutil.freplace('.', shellglobs=('workfile3',),regexl=((r'\\$',r'', None),)) |
All times are GMT -5. The time now is 01:25 PM. |