0
Q:

python read entire file

# "with" closes file for you after use, even if error encountered
# r - read, w - write, rb - read binary, wb - write binary

with open('dog_breeds.txt', 'r') as reader:
     # Read and print the entire file line by line
     for line in reader:
         print(line, end='')
8
with open('pagehead.section.htm','r') as f:
    output = f.read()
2
with open('Path/to/file', 'r') as content_file:
    content = content_file.read()
0

New to Communities?

Join the community