Mega Code Archive
Categories
/
Python Tutorial
/
File
Read bytes into a buffer
filePath = "input.txt" buffer = "Read buffer:\n" file = open(filePath, 'rU') while(1): bytes = file.read(5) if bytes: buffer += bytes else: break print buffer