How to read one byte at a time in Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anthony Liu

    #1

    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


  • Garry Knight

    #2
    Re: How to read one byte at a time in Python?

    In message <mailman.335.10 79137564.19534. python-list@python.org >, Anthony
    Liu wrote:
    [color=blue]
    > Java has functions that read only one byte at a time,
    > do we have such a function in python?[/color]

    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
    garryknight@gmx .net ICQ 126351135
    Linux registered user 182025

    Comment

    • Peter Hansen

      #3
      Re: How to read one byte at a time in Python?

      Anthony Liu wrote:
      [color=blue]
      > Java has functions that read only one byte at a time,
      > do we have such a function in python?[/color]

      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

      Comment

      Working...