The following code...
import sys
if sys.platform == "win32":
import os, msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
sys.stdout.write("This is a sample line of text\n")
...results in the stdio output ending with 0x0d
followed by 0x0a
. stdio is set to binary mode. Why is the write()
call still substituting \r\n
for \n
?
If you're running this under Cygwin, sys.platform
will be 'cygwin'
rather than 'win32'
, but you'll still get line-ending conversion. Are you sure the setmode
is actually running?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With