修改所有pw.sh 并把里面的字符串“dw”都换成“pw”
import os
link = './'
def alter(file,old_str,new_str):
  file_data = ""
  with open(file, "r" ) as f:
    for line in f:
      if old_str in line:
        line = line.replace(old_str,new_str)
      file_data += line
  with open(file,"w") as f:
    f.write(file_data)
for i in os.listdir(link):
    if "pw" in i and i.endswith(".sh"):
       print(i)
       alter(i,"dw","pw")
                    
                
                
            
        
浙公网安备 33010602011771号