Sushen Biswas
Sushen Biswas

Reputation: 552

Print Bangla in pythone

I declare some variables in Bangla without any syntax error.

But when I want to print it, its gives me the error.

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

This is my script it Github: https://github.com/banglaosc/condition/blob/master/condition.py

Cant Print Bangla

Upvotes: 0

Views: 1209

Answers (3)

wjandrea
wjandrea

Reputation: 33107

The encoding is at the bottom right in that PyCharm screenshot: UTF-16LE. The problem is that Python 2 will assume a file is ASCII (per PEP 263), and Python 3 will assume UTF-8 (per the tutorial).

Try switching the file encoding by clicking the UTF-16LE button at the bottom right.

Upvotes: 1

Jubel Ahmed
Jubel Ahmed

Reputation: 44

In your code editor, you can see that your Unicode change with another format (UTF-16LE). Try to convert from UTF-16LE to UTF-8 from the bottom right corner. It's working for me.

Unicode UTF-8 change picture

Upvotes: 2

Alex
Alex

Reputation: 1262

EDIT: The following applies to python3.5+ this will not work in python2.7

When I run your code I do not get that error. Pycharm show it as an error, but the python interpreter has no issue with the characters. The exception actually raised when running this is TypeError because the variable জুকারবার্গ is an int, and you are trying to use the + on it with a string. The following will execute with no errors.

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


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

Upvotes: 0

Related Questions