user2173955
user2173955

Reputation:

Remove \`u2022` unicode special character from python list

I want to remove \u2022 from the dList but i am getting same list again

dList = [u'\u2022 Slim fit',
 u'\u2022 Barrel cuffs with two buttons',
 u'\u2022 One button on sleeve placket',
 u'\u2022 Turndown collar',
 u'Washing Care: ',
 u'\u2022 Machine wash low in cold water',
 u'\u2022 Medium iron',
 u'\u2022 Do not bleach',
 u'\u2022 Hang to dry',
 u'\u2022 Do not tumble dry',
 u'\u2022 Wash separately',
 u'Model\'s measurements: Chest 34", Waist 30", Hips 32"',
 u'Height: 175cm.',
 u'He is wearing a N. Tyler Size 15.5.',
 u'Please note: ',
 u'Although we do our best to make sure that the colours shown on our website are accurate, actual colours may vary due to monitor/display/resolution.',
 u'Dark Blue Checks',
 u'100% Cotton , European Fabric']

[i.replace("\u2022"," ") for i in dList]

Output: 

[u'\u2022 Slim fit',
 u'\u2022 Barrel cuffs with two buttons',
 u'\u2022 One button on sleeve placket',
 u'\u2022 Turndown collar',
 u'Washing Care: ',
 u'\u2022 Machine wash low in cold water',
 u'\u2022 Medium iron',
 u'\u2022 Do not bleach',
 u'\u2022 Hang to dry',
 u'\u2022 Do not tumble dry',
 u'\u2022 Wash separately',
 u'Model\'s measurements: Chest 34", Waist 30", Hips 32"',
 u'Height: 175cm.',
 u'He is wearing a N. Tyler Size 15.5.',
 u'Please note: ',
 u'Although we do our best to make sure that the colours shown on our website are accurate, actual colours may vary due to monitor/display/resolution.',
 u'Dark Blue Checks',
 u'100% Cotton , European Fabric']

Also tried :

import re

[re.sub("\u2022","",i) for i in dList]

But no luck....can someone help me please...

Upvotes: 1

Views: 4229

Answers (2)

Steve
Steve

Reputation: 21499

[x.encode('ascii','ignore') for x in dList]

Should do the trick.

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798676

unicodes are unicodes and strs are strs.

[i.replace(u"\u2022", u" ") for i in dList]

Upvotes: 6

Related Questions