以下代码...
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")
...导致 stdio 输出以0x0d
.结尾0x0a
。stdio 设置为二进制模式。为什么write()
呼叫仍然\r\n
代替\n
?