python读写文件\r\n问题

newline controls how universal newlines mode works (it only applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works as follows:

[...]

  • When writing output to the stream, if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. If newline is '' or '\n', no translation takes place. If newline is any of the other legal values, any '\n' characters written are translated to the given string.
open(..., 'w', newline='')

当newline='\n',read,write数据中的\r\n都不会转化。
上一篇:React-Native iOS真机调试(新版)


下一篇:show()封装没有想象中那么简单