How to convert unicode list to ascii list?

Miki Tebeka tebeka at cs.bgu.ac.il
Thu Mar 20 03:17:22 EST 2003


Hello Mark,

> When I use the following code:
>    groups = win32net.NetUserGetLocalGroups(None, 'username')
> 
> The list returned is in unicode:
>   [u'Debugger Users', u'OLAP Administrators', u'Administrators']
> 
> I tried accessing the elements using:
>    firstElement = groups[0]
> but it returns only this:  '['
> 
> How can I convert this list to a normal ASCII list so that I can access each
> element as ASCII?
ascii_groups = map(lambda s: s.encode('ascii'), groups)

HTH.
Miki




More information about the Python-list mailing list