0

file text replacement

is it possible to access a .txt file and replace all "t" with "a" with open('file.txt', 'r') as f: with open('file.txt', 'w') as w: for t in f.read(): if "t" in t: w.write("a")

27th Nov 2021, 11:59 PM
Tomoe
Tomoe - avatar
1 Antwort
+ 1
- read the text - change the text (e.g. using .replace()) - save the text https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_string_replace.asp
28th Nov 2021, 12:15 AM
Simon Sauter
Simon Sauter - avatar