Answers for "python program to display contents of a file"

1

code for showing contents of a file and printing it in python

import os

with open("filename", "r+") as file:
    content = file.readline()
    while(content!=""):
      	print(content)
        content = file.readline()
    file.close
Posted by: Guest on August-05-2020
1

python print contents of file

f = open("file_name.txt", "r")
print(f.read())
f.close()
Posted by: Guest on May-08-2021

Code answers related to "python program to display contents of a file"

Python Answers by Framework

Browse Popular Code Answers by Language