Advertisement
facedwarrior193

replace strings in file

Jun 23rd, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. i = True
  2. words = {"test","Hi","Hello"}
  3. with open("yes.txt","r") as f:
  4.   f = f.read()
  5.   f = f.casefold()
  6. for i in words:
  7.   i = i.casefold()
  8.   if i in f:
  9.     f = f.replace(i,"@#$&*%")
  10. with open("yes.txt","w") as d:
  11.   d.write(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement