
benjamin.kaplan at case
Jun 18, 2012, 4:18 PM
Post #2 of 6
(467 views)
Permalink
|
|
Re: Read STDIN as bytes rather than a string
[In reply to]
|
|
On Mon, Jun 18, 2012 at 4:13 PM, Jason Friedman <jason [at] powerpull> wrote: > I tried this: > > Python 3.2.2 (default, Feb 24 2012, 20:07:04) > [GCC 4.6.1] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import sys >>>> import io >>>> fh = io.open(sys.stdin) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: invalid file: <_io.TextIOWrapper name='<stdin>' mode='r' > encoding='UTF-8'> >>>> fh = io.open(sys.stdin, "rb") > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: invalid file: <_io.TextIOWrapper name='<stdin>' mode='r' > encoding='UTF-8'> > -- You want to read from sys.stdin.buffer -- http://mail.python.org/mailman/listinfo/python-list
|