How to print to stdout in binary
Robin Becker
robin at jessikat.demon.co.uk
Fri Jul 7 13:55:47 EDT 2000
In article <8k52il$1p2$1 at pollux.ip-plus.net>, Jürgen Hermann <jhe at webde-
ag.de> writes
>
>"Robin Becker" <robin at jessikat.co.uk> schrieb im Newsbeitrag
>news:Oo9IrBA89bZ5EwGY at jessikat.demon.co.uk...
>> try creating wstdout.py
>>
>> import sys
>> sys.stdout.write('123456789\n')
>
>try:
> import msvcrt, os
> msvcrt.setmode(1, os.O_BINARY)
>except:
> pass
>
>import sys
>sys.stdout.write('123456789\n')
>
>[d:\tmp]py binstdout.py >test
>
>[d:\tmp]ls -l test
>-rw-r--r-- 1 544 everyone 10 Jul 7 19:04 test
>
...
that's the answer to the original question; well done.
--
Robin Becker
More information about the Python-list
mailing list