CBSE Class 12 Computer Science Question 65 of 136

Data File Handling — Question 4

Back to all questions
4
Question

Question 4

Write statements to open a binary file 'C:\Myfiles\text1.dat' in read and write mode by specifying the file path in two different formats.

Answer

The two different formats of specifying file path for opening the file C:\Myfiles\text1.dat in read and write mode are:

  1. file1 = open("C:\\Myfiles\\text1.dat", "rb+")

  2. file2 = open(r"C:\Myfiles\text1.dat", "rb+")