file text replacement | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Resposta
+ 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