Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19484 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2012-01-26 14:05 +0100 |
| Last post | 2012-01-26 14:05 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: how to get my character? Peter Otten <__peter__@web.de> - 2012-01-26 14:05 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2012-01-26 14:05 +0100 |
| Subject | Re: how to get my character? |
| Message-ID | <mailman.5121.1327583141.27778.python-list@python.org> |
contro opinion wrote:
> how can i get "你好" from '\xc4\xe3\xba\xc3' ?
>>> print '\xc4\xe3\xba\xc3'.decode("gbk")
你好
General rule: use the decode() method to convert from bytestring to unicode
and encode() to convert from unicode to bytestring.
bytestring.encode(x) will implicitly try
bytestring.decode("ascii").encode(x) which is likely to fail.
Back to top | Article view | comp.lang.python
csiph-web