What is the shortest method to open a text file and display its content?

The shortest way to open a text file is by using “with” command in the following manner:

Example:

  1. with open(“FILE NAME”, “r”) as fp:  
  2.     fileData = fp.read()    
  3. # To print the contents of the file     
  4. print(fileData)  

Output:

"The data of the file will be printed."