Russian language. When sending a message to the bot in Russian, the console displays an error. When sending in English - everything is in order.

#! /usr/bin/env python # -*- coding: utf-8 -*- from vk_api.longpoll import VkLongPoll, VkEventType import vk_api from datetime import datetime vk_session = vk_api.VkApi(token="токен") session_api = vk_session.get_api() longpoll = VkLongPoll(vk_session) for event in longpoll.listen(): if event.type == VkEventType.MESSAGE_NEW: print('Сообщение пришло в: ' + str(datetime.strftime(datetime.now(), "%H:%M:%S"))) print('Текст сообщения: ' + str(event.text)) print(event.user_id) 
  • The token is entered, I hid it on purpose. - TheButterShow
  • Add the full text of the error to the question - Xander
  • @Xander Traceback (most recent call last): File "C: / Users / Admin / PycharmProjects / untitled / 123", line 12, in <module> print ('Message text:' + str (event.text)) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range (128) - TheButterShow
  • Do you have exactly Python 3.6, not Python 2.7? - andreymal 2:13 pm
  • @andreymal yes, it was 2.7, I forgot to change it. Now everything works, thanks - TheButterShow

0