Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107661
| From | Random832 <random832@fastmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Question on List processing |
| Date | 2016-04-26 11:49 -0400 |
| Message-ID | <mailman.111.1461685776.32212.python-list@python.org> (permalink) |
| References | <d0b4c737-3922-4b49-8f69-2564ba472950@googlegroups.com> <571e47aa$0$1588$c3e8da3$5496439d@news.astraweb.com> <594d024b-7880-4d45-911e-342ec90ac54c@googlegroups.com> <1461685768.2496584.590158745.357656B9@webmail.messagingengine.com> |
On Tue, Apr 26, 2016, at 11:38, subhabangalore@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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Question on List processing subhabangalore@gmail.com - 2016-04-25 07:56 -0700
Re: Question on List processing Steven D'Aprano <steve@pearwood.info> - 2016-04-26 02:36 +1000
Re: Question on List processing subhabangalore@gmail.com - 2016-04-26 08:38 -0700
Re: Question on List processing Random832 <random832@fastmail.com> - 2016-04-26 11:49 -0400
Re: Question on List processing Steven D'Aprano <steve@pearwood.info> - 2016-04-27 02:29 +1000
Re: Question on List processing subhabangalore@gmail.com - 2016-04-26 08:44 -0700
Re: Question on List processing Matt Wheeler <m@funkyhat.org> - 2016-04-25 20:31 +0000
csiph-web