Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

How to work with UTF-8 in Python 2.7?

I just want to get UTF-8 working. I tried this:

#!/usr/bin/env python
# -*- coding: utf-8 -*- 
t = "одобрение за"
print t

But when I run this program from the command line, output looks like: одобрение за

I've searched up and down the net, tried the whole sys.setdefaultencoding thing, tried calling encode() and decode(), tried placing the little "u" in front, tried unicode(), etc.

I'm about ready to explode from frustration. Is there a definitive answer for what the heck you're supposed to do?

Answer*

Draft saved
Draft discarded
Cancel

lang-py

AltStyle によって変換されたページ (->オリジナル) /