Can't understand what's wrong with the encoding or what's going on in python?

vk bot returns the result, {body: somedata }
if you display to the console the result to the variable body produces here such

u'\u043f\u0440\u0438\u0432\u0435\u0442'

how to convert to human readable form??

I thought chatterbot does not perceive cirilicu, but there is support there for her as I understand it.
tried so
#if isinstance(msg, unicode):
 # message = msg.encode('utf8')
 #message = u".join(msg.encode('ascii', 'ignore').decode('ascii'))
 #pprint(message)

and here and still falling
msg.encode('utf8').decode('utf8')

I'm a beginner in python and cant understand what the hell was going on already a head broke

In General, this result should be adopted chatterbot to answer but either he falls or vk bot falls with English words do not have this. all the answers and "learn"
June 8th 19 at 16:37
2 answers
June 8th 19 at 16:39
It all depends on the encoding in the console. In MS Windows is CP8665a74338159c0c928836062.png
But I suspect what you have is caused by feature of object serialization:5a74378a2a69d461547604.png
I have here a result. starts to annoy me that Python, to be honest. what am I doing wrong

pprint(msg)
 pprint(msg.encode('CP866'))

the result
u'\u043f\u0440\u0438\u0432\u0435\u0442'
'\xaf\xe0\xa8\xa2\xa5\xe2'
- geoffrey.Tillman commented on June 8th 19 at 16:42
and what is the console(system, program)? And that Python can even on Android to work.

Most likely the console encoding is ASCII which is not imee codes of Russian letters, so the Python string leads to such a mind.

The best solution is to use some sort of interface to output at least square Tk. - Iliana_Strosi commented on June 8th 19 at 16:45
generally the result goes into a chatterbot, and from it comes the answer of the bot, and this is exactly vk_api contact with vk and returns the result above.

all the machinations were made in the program PyCharm CE - geoffrey.Tillman commented on June 8th 19 at 16:48
in General, I realized that you have where instead of str(msg) is repr(msg) - where is the error in the linkage of the modules, it is necessary to check the whole code. Maybe don't set the main encoding to output strings. Easier on the other side to decode perhaps than to look where the dog is buried. - Iliana_Strosi commented on June 8th 19 at 16:51
,

explain to me as a beginner, and I have a whole brain broke th with this "roundnose" Python not

here is the entire code taken part with Habra. I as a novice do not understand what is wrong and why the VC server can not return a normal value strigulae why he gets the kind of rubbish that is not how to ukovernight

the entire project.

Main.py
# -*- coding: utf-8 -*-
import time
import vk_api # <a href="https://github.com/python273/vk_api/wiki">https://github.com/python273/vk_api/wiki</a>
import from Talker Talker
import goslate
from pprint import pprint

vk = vk_api.VkApi(login='+37345934875', password='ksahUAu87Ays')

vk.auth()
values = {'out': 0, 'count': 100, 'time_offset': 60}

def write_msg(user_id, s):
 vk.method('messages.send', {'user_id': user_id, 'message': s})

def read_msg():
 response = vk.method('messages.get', values)
 return response
talker = Talker()

while True:
 response = read_msg()
 answer = "
 if response['items']:
 msg = response['items'][0]['body']
 message = msg.encode('utf8')
pprint(message)
 answer = talker.answerUser(message)
 if answer == "":
 answer = "OK"

 values['last_message_id'] = response['items'][0]['id']
 for item in response['items']:
 write_msg(item[u user_id'], answer)
 response['items'] = ""
 time.sleep(1)


Talker.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import goslate

class Talker(object):
 chatbot = ChatBot("max",
logic_adapters=[
'chatterbot.logic.MathematicalEvaluation'
],
storage_adapter='chatterbot.storage.SQLStorageAdapter',
database='./database.sqlite3')

 def __init__(self):
 conversation = [
"Hello",
 "Hi there!",
 "How are you doing?",
 "I'm doing great.",
 "That is good to hear",
 "Thank you.",
 "You're welcome.",
 "what you want?",
"Lol",
]
self.chatbot.set_trainer(ListTrainer)
self.chatbot.train(conversation)
 def answerUser(self, question):
 return self.chatbot.get_response(question)
- geoffrey.Tillman commented on June 8th 19 at 16:54
June 8th 19 at 16:41
and how to disable the serialization of data ? I am a novice in Python as I understand it, serialization is a bunch of resets of variables in one variable???

Find more questions by tags Python