How is a file read using a limited buffer size using Python?

PythonServer Side ProgrammingProgramming

You can read a file using a limited buffer by specifying the buffer size in the read function. It takes the number of bytes you want to read from the current position of the pointer in the file. 


with open('my_file.txt', 'r') as f:
    print(  # Read and print 10 bytes


This will give the output −

Hello worl

If the file contents were Hello world!

Published on 28-Dec-2017 06:25:51