Oct-12-2020, 05:27 AM
If the Python file below is run on a text file containing the following:
Hello! Welcome to demofile.txt
This file is for testing purposes.
Good Luck!
Why does it return empty spaces in the output between each line of text-like below?
Hello! Welcome to demofile.txt
This file is for testing purposes.
Good Luck!
f=open(r"C:\Users\.....\Documents\demofile.txt")
data=None
while data!="":
#If an empty string is returned,
#the file end is reached
data= f.readline()
print(data[:])
f.close()
Hello! Welcome to demofile.txt
This file is for testing purposes.
Good Luck!
Why does it return empty spaces in the output between each line of text-like below?
Hello! Welcome to demofile.txt
This file is for testing purposes.
Good Luck!
f=open(r"C:\Users\.....\Documents\demofile.txt")
data=None
while data!="":
#If an empty string is returned,
#the file end is reached
data= f.readline()
print(data[:])
f.close()