Decode School

Decode School - The School for Problem Solvers
Welcome to My Blog.
Need Assignment / Project Guidance (or) Training in Python?

File read in python

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

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.