gpt4 book ai didi

python - 从 python 列表中删除\`u2022` unicode 特殊字符

转载 作者:太空宇宙 更新时间:2023-11-04 08:14:15 25 4
gpt4 key购买 nike

我想从 dList 中删除 \u2022 但我又得到了相同的列表

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']

也尝试过:

import re

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

但是没有运气......有人可以帮我......

最佳答案

unicodes are unicodes and strs are strs.

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

关于python - 从 python 列表中删除\`u2022` unicode 特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17272531/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com