Answer the question
In order to leave comments, you need to log in
Why doesn't python display utf-8 cyrillic?
Good day to all, I decided to look at the VK API today and used python, I managed to make a request, I received an answer, but the problem is that the answer comes like this
{u'response': [{u'first_name': u'\u041f\u0430\u0432\u0435\u043b', u'last_name': u'\u0414\u0443\u0440\u043e\u0432', u'id': 1, u'bdate': u'10.10.1984'}]}
# coding:utf8
import requests
req = requests.get('http://api.vk.com/method/users.get?user_ids=1&fields=bdate&v=5.52')
print (req.status_code)
result = req.json()
print result
Answer the question
In order to leave comments, you need to log in
The answer comes right, in Unicode. If you really need to, you can convert to UTF8.
Python and UTF8
https://habrahabr.ru/post/135913/
In python3, all str are in Unicode by default
The characters you write are part of the Cyrillic alphabet
The answer came to you in utf-8
Perhaps requests converted it to utf-8 ascii safe in which each character is represented as a sequence \u041f
In your case, you do not need to convert to unicode - requests will do everything by itself
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question