read text file byte by byte

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Dec 13 01:44:54 EST 2009


On Sat, 12 Dec 2009 22:15:50 -0800, daved170 wrote:

> Thank you all.
> Dennis I really liked you solution for the issue but I have two question
> about it:
> 1) My origin file is Text file and not binary 

That's a statement, not a question.


> 2) I need to read each time 1 byte.

f = open(filename, 'r')  # open in text mode
f.read(1)  # read one byte


-- 
Steven



More information about the Python-list mailing list