data = [item for item in contents.encode('utf-8').split('\r\n')]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1807: ordinal not in range(128)
Why can't it encode it when I encode it?
You must be using Python 2. .encode can only encode Unicode strings. If you try to .encode a byte string, Python 2 will implicitly try to .decode the byte string to Unicode, using the default ascii codec, before using the explicit .encode('utf-8').
contents is already a byte string. If that byte string is encoded in UTF-8, use .decode('utf-8') instead to convert it to a Unicode string.
contents? If it's a byte string, you need to usedecodeto convert it to unicode.