Computer Science

Write a statement in Python to perform the following operations:

(a) To open a text file "BOOK.TXT" in read and append mode

(b) To open a text file "BOOK.TXT" in write mode

(c) To open a text file "BOOK.TXT" in append mode

Python Data Handling

1 Like

Answer

(a) To open a text file "BOOK.TXT" in read and append mode :
file_read_append = open("BOOK.TXT", "a+")

(b) To open a text file "BOOK.TXT" in write mode :
file2 = open("BOOK.TXT", "w")

(c) To open a text file "BOOK.TXT" in append mode :
file_append = open("BOOK.TXT", "a")

Answered By

3 Likes


Related Questions