read text file byte by byte

Lie Ryan lie.1296 at gmail.com
Sun Dec 13 02:25:55 EST 2009


On 12/13/2009 5:15 PM, 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
> 2) I need to read each time 1 byte. I didn't see that on your example
> code.

That's where you're confusing things. The counting unit in text is 
characters, not bytes. Text is binary as well, it's just binary encoded 
in specific way (like ASCII or UTF-8), and computers decoded that binary 
stream into characters.

What you actually need? Reading the text character-per-character OR 
treating an encoded text as binary and reading it byte-per-byte.

Rather, why don't you explain the problem you're trying to solve so we 
can see which you actually need.



More information about the Python-list mailing list