¡@

Home 

python Programming Glossary: replacedtext

Python string replace in a file without touching the file if no substitution was made

http://stackoverflow.com/questions/5286020/python-string-replace-in-a-file-without-touching-the-file-if-no-substitution-was

file into memory thefile.close thefile open match 'w' replacedText content.replace oldtext newtext if replacedText '' count 1 thefile.write.. match 'w' replacedText content.replace oldtext newtext if replacedText '' count 1 thefile.write replacedText thefile.close print count.. oldtext newtext if replacedText '' count 1 thefile.write replacedText thefile.close print count # print the number of files that we..