I have a list with binary type strings looking like this which is obtained by reading a text file in rb
mode (as r
does not work for reading the file due to probable mixed up characters from various encodings):-
new_list = [b'Vanessa Skarski\'s Account of Her Father\'s Death....', b'Hornslet wind-turbine collapse\r\nFrom Wikipedia' .....]
etc.
with a total of 271
items in the list. But I want the list items to be normal strings not binary ones. I have looked into using
new_list = [item.decode(encoding='utf-8') for item in new_list]
but it gives UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 643: invalid start byte
. I simply want to get rid of the b' and get normal strings. Any ideas please?
EDIT The solution mentioned in Convert bytes to a string? did not solve the issue as I already mentioned in my initial post. My Python version is listed below if that has anything do to with the error at all
3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]