Re: [Tutor] How to iterate through unicode string.

2009-09-05 Thread Lie Ryan
Dirk Wangsadirdja wrote: Hi allen (and perhaps this goes also for others), just a suggestion, maybe when we post a problem, we should also mention the python version that we use. Every new subscribers to the tutor mailing list are sent an email that contains this: """ Finally, when you do

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread Dirk Wangsadirdja
Hi allen (and perhaps this goes also for others), just a suggestion, maybe when we post a problem, we should also mention the python version that we use. Sometimes, different version of python would give different results. I tried it with Python 3.1 (python 3.x uses unicode for string) and P

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread zhang allen
Thank you very much. :) it works now. 2009/9/4 Christian Witts > If it's not you can put an encoding line @ the top of your script like > # -*- encoding: utf-8 -*- > > David Stanek wrote: > >> Is the encoding of your file set? >> >> >> On 9/4/09, zhang allen wrote: >> >> >>> Hi Christian, >>>

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread Christian Witts
If it's not you can put an encoding line @ the top of your script like # -*- encoding: utf-8 -*- David Stanek wrote: Is the encoding of your file set? On 9/4/09, zhang allen wrote: Hi Christian, Thanks for your tip. But it seems to me still not working again. i wirte this python code k

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread David Stanek
Is the encoding of your file set? On 9/4/09, zhang allen wrote: > Hi Christian, > > Thanks for your tip. > > But it seems to me still not working again. > > i wirte this python code > > k = [] > s = u'Büro' > for c in s: > k.append(c) > print k > > k=[u'B', u'\xa8', u'\xb9', u'r', u'o'] > >

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread zhang allen
Hi Christian, Thanks for your tip. But it seems to me still not working again. i wirte this python code k = [] s = u'Büro' for c in s: k.append(c) print k k=[u'B', u'\xa8', u'\xb9', u'r', u'o'] i still have 5 different chars. 2009/9/4 Christian Witts > zhang allen wrote: > >> Hi A

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread zhang allen
Hi Andre, i tried this. s = u'Büro' print len(s) prints 5. it seems not working : ) 2009/9/4 Andre Engels > On Fri, Sep 4, 2009 at 2:20 PM, zhang allen wrote: > > Hi All, > > > > Say i have unicode string Büro. > > i want to iterate this string . > > > > i write this python code which doesn

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread Christian Witts
zhang allen 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 ca

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread Andre Engels
On Fri, Sep 4, 2009 at 2:20 PM, zhang allen 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