Ch 7&8 - Library functions & File handling
Ch 7&8 - Library functions & File handling
LIBRARY ROUTINES
FILE HANDLING
File Handling
//Opening the file in Write mode and writing a line of text to it.
OPENFILE File1.Txt FOR WRITE
OUTPUT “Please enter a line of text”
INPUT TextLine
WRITEFILE File1.Txt, TextLine
CLOSEFILE File1.Txt
//Opening the file in Read mode and reading a line of text from it.
OPENFILE File1.Txt FOR READ
READFILE File1.Txt, TextLine
OUTPUT “The file contains this line of text”
OUTPUT TextLine
CLOSEFILE File1.Txt
Python Program
MyFile=open("MyText.txt“ ,"w")
TextLine=input("Please enter a line of text")
MyFile. Write(TextLine)
MyFile. close()