File read in python

Python Program to read the contents of sample.txt file and display it.

Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

#write your code here

Program or Solution

				
			
					
file=open("sample.txt",'r')
print(file.read())
file.close()

			
				
			

Program Explanation

open the file in read mode read all the contents of file using read() method close() the file.

Comments


Related Programs