python script: copy contents and replace a word
a script that will copy the contents from one file to another and also replace the requested word with the other one.
_________________________________________________________________________________________________
#!/usr/bin/env python
the_word=raw_input(‘enter the word to replace –> ‘)
replace_word=raw_input(‘enter the word to replace with –> ‘)
to_file=open(‘/testfile.txt2′, ‘a’)
try:
read_file=open(‘/testfile.txt’)
for searches in read_file:
searches=searches.replace(the_word, replace_word)
to_file.write(searches)
finally:
to_file.close()
_________________________________________________________________________________________________
(Note:- Please take care of indentaion whenever writing a python script, The script posted above, may not be properly indented)








