Unsupported characters in input In Python IDLE

后端 未结 3 770
花落未央
花落未央 2020-12-21 10:38
suffixes = {
    1: [\"ो\", \"े\", \"ू\", \"ु\", \"ी\", \"ि\", \"ा\"]}

When I done message given by IDLE is

Unsupported characters         


        
相关标签:
3条回答
  • 2020-12-21 10:43

    If you don't declare encoding in your first or second line in your python source file, then the python interpreter will use ASCII encoding system to decode the characters in the file. As these characters you used couldn't be decoded by ASCII encoding system, errors happended.

    The solution is as @RemcoGerlich said. Here is the doc.

    The encoding is used for all lexical analysis, in particular to find the end of a string, and to interpret the contents of Unicode literals. String literals are converted to Unicode for syntactical analysis, then converted back to their original encoding before interpretation starts. The encoding declaration must appear on a line of its own.

    0 讨论(0)
  • 2020-12-21 10:49

    What encoding is your source file in?

    If it is UTF8, put the comment

    # -*- coding: utf-8 -*-
    

    at the top of the file.

    0 讨论(0)
  • 2020-12-21 11:10

    This seems to be a known bug in the 2.x IDLE console: http://bugs.python.org/issue15809. A fix was made for Python 3.x, but doesn't appear to be backported.

    Instead, use an alternative console, such as iPython/Jupyter, or a fully-fledged IDE, such as PyCharm.

    0 讨论(0)
提交回复
热议问题