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.
example
with open('my_file.txt', 'r') as f: print(f.read(10)) # Read and print 10 bytes
Output
This will give the output −
Hello worl
If the file contents were Hello world!