UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0x80 in position 3131: invalid start byte

It doesn’t help that you have sys.setdefaultencoding(‘utf-8′), which is confusing things further – It’s a nasty hack and you need to remove it from your code. See https://stackoverflow.com/a/34378962/1554386 for more information The error is happening because line is a string and you’re calling encode(). encode() only makes sense if the string is a Unicode, so Python tries to convert it Unicode first using … Read more

How to print Unicode character in Python?

To include Unicode characters in your Python source code, you can use Unicode escape characters in the form \u0123 in your string. In Python 2.x, you also need to prefix the string literal with ‘u’. Here’s an example running in the Python 2.x interactive console: In Python 2, prefixing a string with ‘u’ declares them as Unicode-type variables, as … Read more