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(f.read(10)) # Read and print 10 bytes
This will give the output −
If the file contents were Hello world!