Does it exist in python something like 'std::endl' in c++ std? Or, how can I get an end line symbol of the current system?
It seems very important thing because an end line symbol may be different in different OSs.
Does it exist in python something like 'std::endl' in c++ std? Or, how can I get an end line symbol of the current system?
It seems very important thing because an end line symbol may be different in different OSs.
The os module has linesep which is the platform-specific string to end a line. However, quoting the docs:
Do not use os.linesep as a line terminator when writing files opened in text mode (the default); use a single
'\n'
instead, on all platforms.
The default Python behaviour for text files and file-like objects is that if your program writes '\n', it will be translated into whatever is appropriate for the local system. So as Mateen Ulhaq wrote, just use '\n'