S
S
Sasha Filinsky2021-08-02 01:28:54
Python
Sasha Filinsky, 2021-08-02 01:28:54

Why is the text read differently?

I am writing a console mail notification.
Wrote everything works like a sweetie, everything \n exposes, etc. But as soon as I decided to put it on the server, then hell happens.
Code that works as it should on the locale breaks on the server. The text becomes unreadable and skips all \n.
Example from below

On LAN:
I came home
Ate Sir
went to bed.

On the server:
I came home Ate sirleg to sleep.


I tried to force a line break from the mail, but this does not help either.
What to do and what could be wrong?
The server costs on Windows

PS I wrote an example as occurs. There are a lot of transfers in the mail, so it just becomes unbearable to read everything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2021-08-02
@hint000

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)

https://docs.python.org/3/library/functions.html#o...
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 reading input from the stream, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' before being returned to the caller. If it is '', universal newlines mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated.
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.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question