#open file and rewrite (comma) to ,
with open('outputFile') as fo:
fo.write(line.replace("(comma)"," , "))
I'm trying to replace the text (comma)
with a literal ,
within a file. When I run the above code, I get the following error: io.UnsupportedOperation: not writable
Any insight as to how to rewrite text within a file would be greatly appreciated.
I've used the below code, and it still won't replace (comma)
with ,
#open file and rewrite (comma) to ,
with open('outputFile.txt', "a+") as fo:
fo.write(fo.replace('(comma)',','))
fo.close()