ここは期待通りに動作しているようです(Pythonの3.5):
>>> f = open('test.txt', 'wb') # write in binary mode so nothing is changed
>>> f.write('both\r\nnewline\ncarriagereturn\rbothagain\r\n'.encode('utf-8'))
40
>>> f.close()
>>> open('test.txt', 'rb').read() # confirm data is intact
>>> b'both\r\nnewline\ncarriagereturn\rbothagain\r\n'
>>> list(open('test.txt', 'r', newline=None)) # universal mode (convert everything to '\n')
['both\n', 'newline\n', 'carriagereturn\n', 'bothagain\n']
>>> list(open('test.txt', 'r', newline='')) # universal mode but leave data unchanged
['both\r\n', 'newline\n', 'carriagereturn\r', 'bothagain\r\n']
>>> list(open('test.txt', 'r', newline='\n')) # split only on '\n'
['both\r\n', 'newline\n', 'carriagereturn\rbothagain\r\n']
>>> list(open('test.txt', 'r', newline='\r')) # split only on '\r'
['both\r', '\nnewline\ncarriagereturn\r', 'bothagain\r', '\n']
>>> list(open('test.txt', 'r', newline='\r\n')) # split only on '\r\n'
['both\r\n', 'newline\ncarriagereturn\rbothagain\r\n']
あなたは検証のためのいくつかのサンプルデータ&コードをポストてもらえますか?
古い「普遍的な改行」サポートを取得しようとしていますか、またはLFをオンライン改行にしますか?解析が「不完全」であることをどのようにテストしていますか? – pvg
^Mが混在しているレコードの場合、 'line'は'^M'で停止し、forループを通して次の反復が '^ M'の直後に始まります。 –
コードを投稿できますか?いくつかのサンプルデータ? 「私が見ることができる」は他の誰かが試すことができないものです。 – pvg