(I am a beginner self-taught programmer)

I wrote a python3 program containing the Cyrillic in str and in block comments. I will give an example of a section of code, so that it is clear what I mean:

print('Загрузка...') try: f = open('bufer.txt', 'r') # Читаем буфер except FileNotFoundError: print('Файл с базой данных в директории программы не найден') 

The program (and its copies) worked for a long time perfectly in various Windows and Linux systems, both in various IDEs and directly. After the copy of the script was copied to the remote server (Ubuntu) and started from it, the encoding error was displayed:

Traceback (most recent call last): File "1.py", line 28, in print ('**************** <<< \ u041c \ u043e \ u0434 \ u0443 \ u043b \ u044c AstroVK v1 >>> *************** ') UnicodeEncodeError:' ascii 'codec cann’t bother in 128: ordinal not in range (128)

28 line I have this:

 28. print('****************<<< Модуль AstroVK v1 >>>****************') 

I can not understand what's the matter, because the encoding is given at the beginning of the UTF-8 file

 #!/usr/bin/python3 # -*- coding: utf-8 -*- 
  • make sure the file is actually saved in utf8 without a BOM. try to add to the lines the prefix 'u' print(u'здесь текст') - Maxim Timakov
  • 3
    Does the encoding in the remote server console support Cyrillic? - Nikmoon
  • is decided. The reason was precisely in the encoding of the server console - MIKS

0