fork download
  1. import os
  2. import sys
  3.  
  4. sought = sys.argv[1]
  5. replace = sys.argv[2]
  6. source = sys.argv[3]
  7.  
  8. f = open(source, "w")
  9.  
  10. while True:
  11. line = f.readline()
  12. resultFind = line.find(sought)
  13.  
  14. if not resultFind == -1:
  15. resultFind += len(sought) - 1
  16. line = replace + line[resultFind : 0]
  17. f.writelines(line)
  18. print("ok")
  19.  
  20. f.close()
Runtime error #stdin #stdout #stderr 0.01s 9024KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 4, in <module>
IndexError: list index out of range