Can I change a unicode char to gb2312 using python?
Oleg Broytmann
phd at phd.pp.ru
Wed Dec 19 09:07:56 EST 2001
On Wed, Dec 19, 2001 at 09:46:41PM +0800, Kick wrote:
> I know that Java have a method that can manually encode string, like that,
> System.out.println(new String("some chinese char".getBytes()"GB2312"))
>
> Is there any python function or method can do the same work?
http://www.python.org/doc/current/lib/string-methods.html
Python strings has method "encode":
u'sigma'.encode('gb2312')
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list