469,929 Members | 1,918 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

How to read one byte at a time in Python?

Java has functions that read only one byte at a time,
do we have such a function in python?
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

Jul 18 '05 #1
2 4245
In message <ma**************************************@python.o rg>, Anthony
Liu wrote:
Java has functions that read only one byte at a time,
do we have such a function in python?


inf = open('filename', 'r')
c = inf.read(1)

Depending on the meaning of the word 'byte' in your question, you might want
to make the file mode 'rb'.

--
Garry Knight
ga*********@gmx.net ICQ 126351135
Linux registered user 182025
Jul 18 '05 #2
Anthony Liu wrote:
Java has functions that read only one byte at a time,
do we have such a function in python?


Skip assumed you meant during user input. Is that what you meant, or
did you mean during input from a file or something? read(1) would do
that, of course...

-Peter
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by bearophileHUGS | last post: by
1 post views Thread by praba kar | last post: by
1 post views Thread by Jose Reckoner | last post: by
6 posts views Thread by placid | last post: by
18 posts views Thread by gregpinero | last post: by
5 posts views Thread by Thomas Christensen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.