不完全理解这些差异是如何在幕后运作的;
当代码使用"b"
打开一个文件时,有no翻译. 文件中的内容就是读取的内容. 写入文件的内容都已写入.
When code does not use "b"
to open a file, there is a potential translation. An outgoing "\n"
may get translated into "\r\n"
, "\r"
, "\n"
or something else. The last write may append a Ctrl z or not. The beginning of the file may include a BOM. Other translations are possible. Reading of such files may consume the above mentioned and present the code with less info. There are many implementation specific aspects to reading and writing such a text file.
读/写text文件时,不要使用"b"
.否则,不要以"b"
开头.
我该如何着手在我的版本中实现此功能?
如果读取text文件,请不要使用"b"
,否则使用"b"
.