Only on Windows, in the latter case, .write('\n') writes one byte with a value of 10. In the first case, it writes two bytes with a value of 13 and 10.
You can prove it yourself by looking at the resulting file size and view the files in a hex editor.
On POSIX-related operating systems (UNIX, SunOS, MacOS, Linux, etc.), there is no difference between 'w' and 'wb' .
source share