Question on List processing

Random832 random832 at fastmail.com
Tue Apr 26 11:49:28 EDT 2016


On Tue, Apr 26, 2016, at 11:38, subhabangalore at gmail.com wrote:
> I am trying to send you a revised example.
> list1=[u"('koteeswaram/BHPERSN engaged/NA ','class1')",
> u"('koteeswaram/BHPERSN is/NA ','class1')"] 
> 
> [('koteeswaram/BHPERSN engaged/NA ','class1'),
>  ('koteeswaram/BHPERSN is/NA  ','class1')]
> 
> I tried to make it as follows,
> list2=[]
> for i in list1:
>         a1=unicodedata.normalize('NFKD', i).encode('ascii','ignore')
>         a2=a1.replace('"',"")
>         list2.append(a2)

I think you're still a bit confused. The values don't actually contain
'"' (or 'u'), that's just an indicator that they're strings. You can't
turn a string into something else just by removing the quotes. Look at
the ast.literal_eval function as others have recommended.



More information about the Python-list mailing list