Can I change a unicode char to gb2312 using python?

Kick store_li at sina.com
Thu Dec 20 03:41:14 CET 2001


Thank you! But what I want to change is a variable. How can I use this
method? Just f.encode("gb2312")?

But python told me that out of range(128).What shall I do ?

Thank you!
"Oleg Broytmann" <phd at phd.pp.ru> wrote in message
news:mailman.1008770961.5358.python-list at python.org...
> 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