Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98509

Re: using binary in python

From Michiel Overtoom <motoom@xs4all.nl>
Newsgroups comp.lang.python
Subject Re: using binary in python
Date 2015-11-09 11:40 +0100
Message-ID <mailman.168.1447065689.16136.python-list@python.org> (permalink)
References <20151108212706.GA29701@z-sverige.nu>

Show all headers | View raw


> On 08 Nov 2015, at 22:27, kent nyberg <kent@z-sverige.nu> wrote:
> 
> Well, lets assume I want to write and read binary.  How is it done?

With the functions 'open()' and 'read()' and 'write()'. If you're on Windows, don't forget to include a 'b' in the mode string of the open() call, otherwise Python will assume that you're opening a text file.

You also might want to look into the 'struct' module, functions 'pack()' and 'unpack()'. They convert python values to their binary representation which is used in binary files.

Greetings,


Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: using binary in python Michiel Overtoom <motoom@xs4all.nl> - 2015-11-09 11:40 +0100
  Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 12:56 +0200
    Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-09 22:04 +1100
      Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 15:25 +0200
        Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 00:52 +1100
          Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 16:32 +0200
            Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 02:17 +1100
              Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 17:46 +0200
                Re: using binary in python Chris Angelico <rosuav@gmail.com> - 2015-11-10 02:57 +1100
                Re: using binary in python Marko Rauhamaa <marko@pacujo.net> - 2015-11-09 18:17 +0200

csiph-web