R
rorley
I'm trying to open a text file, remove all instances of the words
"f=x;" and "i=x;" where x can be any number 0-14. Also, I want to
remove all { " or ) or ( or ' } each time one of those characters
occurs respectively. This is what I've been able to piece together...
import os, string
x = ("f=;")
y = ("i=
inputFile = open('abcd.txt','r')
data = inputFile.read()
inputFile.close()
search = string.find(data, x)
if search >=1:
data = data.replace(x)
data = data.replace(y)
outputFile = open('abcd.txt','w')
outputFile.write(data)
outputFile.close()
This doesn't work, even to just remove "f=;". Any help would be great.
Thanks,
Reece
"f=x;" and "i=x;" where x can be any number 0-14. Also, I want to
remove all { " or ) or ( or ' } each time one of those characters
occurs respectively. This is what I've been able to piece together...
import os, string
x = ("f=;")
y = ("i=
inputFile = open('abcd.txt','r')
data = inputFile.read()
inputFile.close()
search = string.find(data, x)
if search >=1:
data = data.replace(x)
data = data.replace(y)
outputFile = open('abcd.txt','w')
outputFile.write(data)
outputFile.close()
This doesn't work, even to just remove "f=;". Any help would be great.
Thanks,
Reece