In Python: saving Unicode letters with newlines into a .txt so that it works fine while opening both using Excel and a text editor
Question: I want to save some unicode data into a .txt file, so that it looks OK while
opening the same file both in text editor and using Excel. Tried to
codecs.open() the txt file using different encodings, but this "codecs"
library does not show newlines, what is not OK while opening the txt file in
file explorer, however when I open it in Excel I can see newlines. But I also
need to see my unicode letters. I cannot manage to have both (unicode symbols
and newlines) in both ways of opening the txt file..


Answer: `codecs.open()` doesn't convert `'\n'` (newline) to `os.linesep` (`'\r\n'` on
Windows). You could try `io.open()` instead:

    
    
    import io
    
    with io.open(r'c:\path\to\output.txt', 'w', encoding='utf-8-sig') as file:
        file.write(u"abc\n")
        file.write(u"\u2744\n")
    

