I am new to python. I need help to program a code with which you can select a character to be replaced by another also selectable in a text file.
pregunta1 = input("Carácter para reemplazar : ") pregunta2 = input("Nuevo carácter : ") contenido = open("Archivo.txt", "r").read() contenido.replace(pregunta1, pregunta2)
This is my code.
My interpretation of the problem:
Possibly what you are looking for is to replace all the characters of a text file to later rewrite the same file with a change in terms of characters, if that is the case a solution based on my logic would be to use the "open()" function and assign two terms, the first would be the file path and the second would be the specification, in this case "w" to rewrite the file. We then write the replaced content into the file and finally use the "close()" method to release resources.
Code based on my proposal: