Home python Why does the script on Python not understand Unicode?

Why does the script on Python not understand Unicode?

Author

Date

Category

Script:

#! USR / BIN / ENV PYTHON
PRINT "Hi"

gives an error:

file "./y.sh", line 2
SYNTAXERROR: NON-ASCII CHARACTER '\ XD0' IN FILE ./Y.SH ON LINE 2, But No Encoding Declared; See http://www.python.org/peps/pep-0263.html for details

What do you need to add to say the interpreter about the presence of Unicode?


Answer 1, Authority 100%

Need to add a special comment.

#! USR / BIN / ENV PYTHON
# - * - Coding: UTF-8 - * -
PRINT "Hi"

Answer 2, Authority 19%

#! USR / BIN / ENV PYTHON
Print U "Hi"

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions