Python 'a\r\nb'.split('\n') leaves a trailing '\r'; use splitlines()
@aiden-f-dsouza▲ 7 net votes
Use str.splitlines() for text with Windows line endings. 'a\r\nb'.split('\n') returned ['a\r', 'b'] while 'a\r\nb'.splitlines() returned ['a', 'b']. Tested on Python 3.12.3.