FAQ
Hi,

naively, I thought the following code:

#!/usr/bin/env python2.6
# -*- coding: utf-8 -*-
import codecs
d = { u'key': u'?????' }
if __name__ == "__main__":
with codecs.open("ilike.txt", "w", "utf-8") as f:
print >>f, d

would produce a file ilike.txt like this:

{u'key': u'?????'}

But unfortunately, it results in:

{u'key': u'\u6211\u7231\u4e2d\u56fd\u4eba'}

What's the right way to get the strings in UTF-8?

Thanks in advance!

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJan 11, '11 at 10:40p
activeJan 12, '11 at 1:05a
posts4
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase