How to edit file by using open, read, write and close options in python shell | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to edit file by using open, read, write and close options in python shell

when I write: file=open("myfile.py") reading=file.read() print(reading) it just skips one blank line and shows >>>

2nd Mar 2018, 11:11 AM
MARTIAN#ANUBHAV
MARTIAN#ANUBHAV - avatar
2 Answers
+ 9
try this with open(filename,"r") as myfile: for line in myfile.read(): print(line)
2nd Mar 2018, 11:28 AM
__Nick
__Nick - avatar
+ 1
@_Nick thanks
2nd Mar 2018, 11:40 AM
MARTIAN#ANUBHAV
MARTIAN#ANUBHAV - avatar