[Tutor] How to iterate through unicode string.
zhang allen
acallen99 at gmail.com
Fri Sep 4 14:33:49 CEST 2009
Hi Andre,
i tried this.
s = u'Büro'
print len(s)
prints 5.
it seems not working : )
2009/9/4 Andre Engels <andreengels at gmail.com>
> On Fri, Sep 4, 2009 at 2:20 PM, zhang allen<acallen99 at gmail.com> wrote:
> > Hi All,
> >
> > Say i have unicode string Büro.
> > i want to iterate this string .
> >
> > i write this python code which doesn't work.
> >
> > s ='Büro'
> > for ch in s:
> > print ch
> >
> > it seems Büro has 5 chars. ü consists of 2 bytes.
> >
> > so does someone has any ideas?
> >
> > how to iterate this string, so i can hava 4 chars, like "B, ü, r, o ".?
> >
> > Thanks in advance.
>
> Try replacing
> s ='Büro'
> by
> s = u'Büro'
>
> The 'u' denotes that the string is to be interpretred as unicode.
>
>
>
> --
> André Engels, andreengels at gmail.com
>
--
Best Regards,
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090904/2a3513e7/attachment.htm>
More information about the Tutor
mailing list