首页 > 解决方案 > Python Cryllic Terminal Input not working

问题描述

I have gotten the Cryllic alphabet to appear properly during script output, but typing into the terminal always appears in ASCII. Is there a way for a user to input Cryllic for storing as a string? below is some example code.

var = input(str)
    varB = var.lower()
    if varB == "да":

user inputs "Да", but console shows "da", causing boolean to return False

标签: pythonpython-3.xencodingcodeccyrillic

解决方案


您必须将 python 文件的编码设置为utf-8.

这可以通过将以下字符串放在脚本文件的顶部来完成:

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

您可以在文档此答案中找到有关它的更多信息


推荐阅读