close

[Solved] Syntax: Non-UTF-8 code starting with ‘\x91’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Syntax: Non-UTF-8 code starting with ‘\x91’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Syntax: Non-UTF-8 code starting with ‘\x91’ Error Occurs?

Today I get the following error Syntax: Non-UTF-8 code starting with ‘\x91’ in python.

How To Solve Syntax: Non-UTF-8 code starting with ‘\x91’ Error ?

  1. How To Solve Syntax: Non-UTF-8 code starting with '\x91' Error ?

    To Solve Syntax: Non-UTF-8 code starting with '\x91' Error Python is having none of it. It wants source code saved in UTF-8 and using ' or " for quotation marks. Use notepad, or better still, IDLE to edit your Python code instead.

  2. Syntax: Non-UTF-8 code starting with '\x91'

    To Solve Syntax: Non-UTF-8 code starting with '\x91' Error Python is having none of it. It wants source code saved in UTF-8 and using ' or " for quotation marks. Use notepad, or better still, IDLE to edit your Python code instead.

Solution 1

Your editor replaced ' (ASCII 39) with U+2018 LEFT SINGLE QUOTATION MARK characters, usually a sign you used Word or a similar wordprocessor instead of a plain text editor; a word processor tries to make your text ‘prettier’ and auto-replaces things like simple quotes with fancy ones. This was then saved in the Windows 1252 codepage encoding, where the fancy quotes were saved as hex 91 characters.

Python is having none of it. It wants source code saved in UTF-8 and using ' or " for quotation marks. Use notepad, or better still, IDLE to edit your Python code instead.

You have numerous other errors in your code; you cannot use spaces in your variable names, for example, and Python uses and, not & as the boolean AND operator. != is an operator requiring 2 operands (it means ‘not equal’, the opposite of ==), the boolean NOT operator is called not.

Solution 2

Add this line at the top of you code. It may work.

    # coding=utf8

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read