开发者

how to encode string with unicode characters python

开发者 https://www.devze.com 2023-03-07 03:14 出处:网络
I have a sql statement: select \'ó\' from dual; after running fetchall for this statement I get the following string.\'\\xc2\\xbf\' in python.

I have a sql statement: select 'ó' from dual; after running fetchall for this statement I get the following string.'\xc2\xbf' in python.

How do I get the original text based on the string returned? any ideas?

thanks!

Update: It turns out that the fetchall might be converting the '开发者_开发技巧ó' to an inverted questionmark(the \xc2\xbf). any ideas why that is. I'm using

#!/usr/bin/env python
# -*- coding: latin-1 -*-
??


http://docs.python.org/library/stdtypes.html#str.decode is what you're looking for.

0

精彩评论

暂无评论...
验证码 换一张
取 消