Unsupported characters in input In Python IDLE

2019-01-28 09:07发布

suffixes = {
    1: ["ो", "े", "ू", "ु", "ी", "ि", "ा"]}

When I done message given by IDLE is

Unsupported characters in input

Also not see the proper font in MS-DOS.

3条回答
戒情不戒烟
2楼-- · 2019-01-28 09:34

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.

查看更多
We Are One
3楼-- · 2019-01-28 09:39

What encoding is your source file in?

If it is UTF8, put the comment

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

at the top of the file.

查看更多
Fickle 薄情
4楼-- · 2019-01-28 09:45

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.

查看更多
登录 后发表回答