Answer the question
In order to leave comments, you need to log in
How to make python 2 friends with cyrillic?
How to make the second python work with cyrillic? I looked through a bunch of sources, nothing helped. Tried to write
import sys
reload(sys)
sys.setdefaultencoding('UTF8')
I tried
other ways, nothing helped.
What should I do if, for example, I parsed json and want to get a value from it (the value is a string with Cyrillic characters), like thiss.decode('utf-8')
s = data['weather'][0]['description'].decode('utf-8')
Answer the question
In order to leave comments, you need to log in
Read " Unicode HOWTO " to the fullest.
Absolutely not to be used sys.setdefaultencoding()
! If such an example is given in some source, know that this source is bad and it is better not to refer to it anymore.
What does "nothing worked" mean? Does the computer shut down when you call the decode method?
Obviously, get it if you want.
PS Python 2 was deprecated 10 years ago.
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import locale
locale.setlocale(locale.LC_ALL, 'ru_RU.UTF8')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question