Computer Science
Write a statement in Python to perform the following operations :
(a) To open a text file "BOOK.TXT" in read mode
(b) To open a text file "BOOK.TXT" in write mode
Python File Handling
1 Like
Answer
(a) To open a text file "BOOK.TXT" in read mode : file1 = open("BOOK.TXT", "r")
(b) To open a text file "BOOK.TXT" in write mode : file2 = open("BOOK.TXT", "w")
Answered By
3 Likes
Related Questions
What are the advantages of saving data in :
(i) binary form
(ii) text form
(iii) csv files ?
When do you think text files should be preferred over binary files ?
When a file is opened for output in append mode, what happens when
(i) the mentioned file does not exist
(ii) the mentioned file does exist.
How many file objects would you need to create to manage the following situations ? Explain.
(i) to process three files sequentially
(ii) to merge two sorted files into a third file.