2018-05-15 OSの改行文字を得る python 標準ライブラリOSには色々と便利な関数があります。 実際のところ import os os.linesep #>> '\n' これがwindowsだと import os os.linesep #>> '\r\n' 参考もと How can I remove (chomp) a trailing newline in Python? - Stack Overflow 16.1. os — Miscellaneous operating system interfaces — Python 3.6.5 documentation