在 python 中打印 Bangla

Print Bangla in pythone

我在孟加拉语中声明了一些变量,没有任何语法错误。

但是当我想打印它时,它给了我错误。

SyntaxError: Non-UTF-8 code starting with '\xff' in file D:/Project/Python Tutorials Repo/condition/condition.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

这是我的脚本吧Github:https://github.com/banglaosc/condition/blob/master/condition.py

编辑:以下适用于 python3.5+ 这在 python2.7

中不起作用

当我 运行 你的代码时,我没有得到那个错误。 Pycharm 将其显示为错误,但 python 解释器对字符没有问题。 运行ning this is TypeError 时实际引发的异常是因为变量 জুকারবার্গ 是一个 int,而您正试图将 + 与字符串一起使用。以下将无错误地执行。

বিল_গেটস = 20
জুকারবার্গ = 30
ওয়ারেন_বাফেট = 35
ইলন_মাস্ক = 10


if বিল_গেটস > জুকারবার্গ:
    print(str(বিল_গেটস) + "বেশি ধনি")
else:
    print(str(জুকারবার্গ) + "বেশি ধনি")

编码位于 PyCharm 屏幕截图的右下角:UTF-16LE。 PEP 263 says Python will assume a file is ASCII, but it looks like that's been switched to UTF-8 in Python 3.

点击右下角的 "UTF-16LE" 尝试将文件编码切换为 UTF-8。如果那不可能,请在脚本顶部声明编码,如下所示:

# -*- coding: UTF-16LE -*-

unicode UTF-8 change picture

在此图像中,您可以看到红色标记。在您的代码编辑器中,您可以看到您的 Unicode 已更改为另一种格式 (UTF-16LE)。尝试从右下角使用 Unicode UTF-16LE 转换为 UTF-8。它对我有用。