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


Groups > comp.lang.python > #98667

How to get 'od' run?

X-Received by 10.129.83.85 with SMTP id h82mr11347400ywb.0.1447297477162; Wed, 11 Nov 2015 19:04:37 -0800 (PST)
X-Received by 10.50.25.131 with SMTP id c3mr287216igg.6.1447297477101; Wed, 11 Nov 2015 19:04:37 -0800 (PST)
Path csiph.com!au2pb.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!b51no69757qgf.0!news-out.google.com!l1ni1359igd.0!nntp.google.com!i2no599405igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Wed, 11 Nov 2015 19:04:36 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=50.100.117.144; posting-account=SZ_svQkAAACWRFG2bDA-zgq8ILyl4-vo
NNTP-Posting-Host 50.100.117.144
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <24ed2ddb-aaea-455e-bf45-10e1cd8e8376@googlegroups.com> (permalink)
Subject How to get 'od' run?
From fl <rxjwg98@gmail.com>
Injection-Date Thu, 12 Nov 2015 03:04:37 +0000
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Received-Bytes 1786
X-Received-Body-CRC 2241529106
Xref csiph.com comp.lang.python:98667

Show key headers only | View raw


Hi,

I am learning python. I see a previous post has such code:





   >>> data = '"binääridataa"\n'.encode('utf-8') 
   >>> f = open('roska.txt', 'wb') 
   >>> f.write(data) 
   17 
   >>> f.close() 

The .encode methods produced a bytestring, which Python likes to display 
as ASCII characters where it can and in hexadecimal where it cannot: 

   >>> data 
   b'"bin\xc3\xa4\xc3\xa4ridataa"\n' 

An "octal dump" in characters (where ASCII, otherwise apparently octal) 
and the corresponding hexadecimal shows that it is, indeed, these bytes 
that ended up in the file: 

$ od -t cx1 roska.txt 


When I run the above line with python 2.7, it does not recognize 'od'.

Is it from a package? Or some internal function?

Thanks,

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


Thread

How to get 'od' run? fl <rxjwg98@gmail.com> - 2015-11-11 19:04 -0800
  Re: How to get 'od' run? Michael Torrie <torriem@gmail.com> - 2015-11-11 20:21 -0700
  Re: How to get 'od' run? Michael Torrie <torriem@gmail.com> - 2015-11-11 20:34 -0700

csiph-web