Answer the question
In order to leave comments, you need to log in
Python + Cyrillic?
Situation: there is a console application in Python (version 2.7). During operation, the application should output (no need to read, I don’t know if this is important) data to the console, including text in Russian. Problem
def __str__(self):
return "%s |(%s)|" % (self.name, self.id)
def __str__(self):
return "%s |(%s)|" % (repr(self.name.encode("UTF-8")), self.id)
Answer the question
In order to leave comments, you need to log in
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Foo(object):
def __init__(self, name):
self.name = name
def __str__(self):
return 'str: %s' % self.name
def __unicode__(self):
return 'uni: %s' % self.name.decode('utf-8')
def __repr__(self):
return 'repr: %s' % self.name
a = 'Елена S'
b = Foo(a)
print(str(b))
print(unicode(b))
print(repr(b))
str: Elena S
uni: Elena S
repr: Elena S
Dear author!
I thought long and hard about what's going on!
until I read your article
versin python 2
-*- coding: utf-8 -*-
word="words"
print 'word'
alas it didn't support language support modules !
and my problem was that when working with the eclipse mars program, he convulsively showed all the words output by the program as an error and gave out the number of the memory cell code in which this obscure object was stored.
that's what helped!
sudo apt-get install python 3
and of course changing the python 2 compiler to a newer version!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question