Files Types of Files Text File Opening Text File Access mode Image taken from NCERT text book Writing to Text File Write() method Filo = open(‘C:\san\sample.txt’,’w’) Filo.write(“welcome”) Filo.close() Output 7 Writeline() method Filo = open(‘C:\san\sample.txt’,’w’) Filo.writelines([“welcome\n”,”to python\n”,”Byee\n”]) Filo.close() Reading from text file read() Filo = open(‘C:\san\sample.txt’,’w’) Filo.writelines([“welcome\n”,”to python\n”,”Byee\n”]) Filo.close() Filo = open(‘C:\san\sample.txt’,’r’) Filo.read(5) Filo.close() Output