从python 3中的字符串中删除某些字符

叉2k

我有设置在的字符串 bp

s1 = '[\'<li class="list__item">Accommodates most miter saws; free adapter brackets ' \
'for offset mounting holes with holes included</li>\', \'<li class="list__item">' \
'Trigger handle quick release tool mounts for mounting or removing miter saw ' \
'quickly and easily</li>\', \'<li class="list__item">Adjustable arms extend out to ' \
'provide 116 in. of material support</li>\', \'<li class="list__item">Fast and easy ' \
'setup with snap pin lock folding legs</li>\', \'<li class="list__item">Easy height ' \
'adjustment of material supports with no tools required</li>\', \'<li ' \
'class="list__item">Stand collapses down quickly for easy storage and transport</li>\', ' \
'\'<li class="list__item">20 in. quick attach tool mounts may be used as miter saw base ' \
'on most surfaces</li>\', \'<li class="list__item">Durable powder-coated finish</li>\', ' \
'\'<li class="list__item">Includes: folding portable miter saw stand and operator ' \
' manual</li>\', \'<li class="list__item">90-day returnable</li>\']'

我想删除所有的 '[\' 和 \ 以及逗号有什么办法可以做到吗?

迈克尔·斯沃茨

你没有说用什么替换它们,所以我用空字符串替换它们

#!python3

s1 = '[\'<li class="list__item">Accommodates most miter saws; free adapter brackets ' \
'for offset mounting holes with holes included</li>\', \'<li class="list__item">' \
'Trigger handle quick release tool mounts for mounting or removing miter saw ' \
'quickly and easily</li>\', \'<li class="list__item">Adjustable arms extend out to ' \
'provide 116 in. of material support</li>\', \'<li class="list__item">Fast and easy ' \
'setup with snap pin lock folding legs</li>\', \'<li class="list__item">Easy height ' \
'adjustment of material supports with no tools required</li>\', \'<li ' \
'class="list__item">Stand collapses down quickly for easy storage and transport</li>\', ' \
'\'<li class="list__item">20 in. quick attach tool mounts may be used as miter saw base ' \
'on most surfaces</li>\', \'<li class="list__item">Durable powder-coated finish</li>\', ' \
'\'<li class="list__item">Includes: folding portable miter saw stand and operator ' \
' manual</li>\', \'<li class="list__item">90-day returnable</li>\']'

s1 = s1.replace("[", "").replace("\\", "").replace(",", "").replace("]", "")

print(s1)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Python 3剥离列表中的某些字符的字符串

Python:如何删除字符串中的某些单词

从python字符串中删除某些字符串块

删除字符串 Python 中的字符

尝试从Python 3中的字符串中删除字母

用预定义的替换字符替换输入字符串中的某些字符(python 3)

删除所有内容,直到python中的某些字符串或字符为止

如果某些字符不在字符串#python中的特定位置,请删除它们

在Python中删除特定的字符/字符串/字符序列

python如何大写字符串中的某些字符

在python中,如何从字符串中提取某些字符?

从python字符串中删除\ n

从python字符串中删除引号

从字符串中删除前缀 | Python

使用Python中的字符串字典替换某些短语中的某些字符串

在 Python 中删除字符串而不删除重复字符

从python中的字符串中删除控制字符

从Python中的字符串中删除奇怪的隐藏字符

使用strip()从Python中的字符串中删除字符

从 Python 元组列表中的字符串中删除字符

从 Python 中的字符串中删除特定的重复字符

python,从列表中的字符串中删除字符

从Python中的字符串中删除特定字符

从python中的字符串中删除前导空字符

从Python中的字符串中删除LaTeX字符

在python中删除字符串中的连续重复字符

从Python中的字符串中删除特殊字符

如何在Python 3中删除字符串中的特殊字符?

在 python 3.x 中,如何从列表中的字符串中删除子字符串?