CBSE Class 12 Computer Science Question 106 of 136

Data File Handling — Question 45

Back to all questions
45
Question

Question 45

Write a statement to open a binary file C:\Myfiles\Text1.dat in read and write mode by specifying for file path in two different formats.

Answer

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

  1. file1 = open("C:\\Myfiles\\Text1.txt", "rb+")

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