Line reading chokes on 0x1A

后端 未结 2 1106
[愿得一人]
[愿得一人] 2020-11-28 14:37

I have the following file:

abcde
kwakwa
<0x1A>
line3
linllll

Where <0x1A> represents a byte with the hex value of

2条回答
  •  天命终不由人
    2020-11-28 15:12

    0x1A is Ctrl-Z, and DOS historically used that as an end-of-file marker. For example, try using a command prompt, and "type"ing your file. It will only display the content up the Ctrl-Z.

    Python uses the Windows CRT function _wfopen, which implements the "Ctrl-Z is EOF" semantics.

提交回复
热议问题