How can I open a file, Stud.txt, and then replace any occurences of \"A\" with \"Orange\"?
with open("Stud.txt", "rt") as fin: with open("out.txt", "wt") as fout: for line in fin: fout.write(line.replace('A', 'Orange'))