【发布时间】:2021-06-10 18:26:28
【问题描述】:
我知道要删除一个反斜杠,我们可能会做类似的事情 来自Removing backslashes from a string in Python
我已经尝试过:
我想知道如何删除列表下方的所有单词,例如 '\ue606',
A =
['Historical Notes 1996',
'\ue606',
'The Future of farms 2012',
'\ch889',
'\8uuuu',]
把它变成
['Historical Notes 1996',
'The Future of farms 2012',]
我试过了:
A = ['Historical Notes 1996',
'\ue606',
'The Future of farms 2012',
'\ch889',
'\8uuuu',]
for y in A:
y.replace("\\", "")
A
返回:
['Historical Notes 1996',
'\ue606',
'The Future of farms 2012',
'\\ch889',
'\\8uuuu']
我不确定如何处理 '\' 后面的字符串,或者为什么它添加了一个新的 '\' 而不是删除它。
【问题讨论】:
-
你试过什么?你在哪里卡住?根据How to Ask,Stack Overflow 通常希望您在发帖之前真诚地尝试自己满足您的要求。
-
感谢@esqew 的反馈。我对此进行了尝试。我对 python 很陌生,所以我知道我的尝试是不正确的,但希望它能提供一些关于我在哪里的见解