Answer the question
In order to leave comments, you need to log in
How to display the entire contents of a file?
How to display the entire contents of the file, I need the code to be reduced to 1-2 lines, so
with open('g.txt', 'r') as fnot suitable, for a better explanation, I need to combine the first lines of the code I presented into one
A=f.read()
print (A)
Answer the question
In order to leave comments, you need to log in
the same can be shortened:
with open('g.txt', 'r') as f:
print(f.read())
with open('g.txt', 'r') as f: print(f.read())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question