SoFunction
Updated on 2024-11-18

Example of python string replacement


#-*- coding:utf-8 -*-
#!/usr/bin/python  

import os

# Define the program root directory
rootpath='D:\\wamp\\www\\erp\\app'

def m_replace(path):
 for item in (path):
  nowpath=(path,item)
  if (nowpath):
   m_replace(nowpath)
  else:
   if ('.php')>0:
    f=open(nowpath,'r+')
    content=().replace('& new ','new ')
    open(nowpath,'w').write(str(content))
    ()

if __name__=="__main__":
 m_replace(rootpath)