【发布时间】:2020-03-06 16:04:22
【问题描述】:
我对编程和 Python 还是很陌生。我有一个字符串列表:
['Iraqi', 'Freedom/Operation', 'New', 'Dawn', 'and', 'Operation', 'Enduring',
'Freedom', '(Afghanistan),', 'have', '(other', 'than', 'call', 'publications)']
如何清除两个单词之间的所有斜线以及包含在任何单词/单词中的括号。干净的数据是:
['Iraqi', 'Freedom', 'Operation', 'New', 'Dawn', 'and', 'Operation', 'Enduring',
'Freedom', 'Afghanistan,', 'have', 'other', 'than', 'call', 'publications']
【问题讨论】:
-
欢迎堆栈溢出!根据您自己的研究,了解到目前为止您感到疲倦会有所帮助;
re.sub、str.replace等?请注意,我们在 stackoverflow 上要求 minimal reproducible example
标签: python regex python-3.x string data-cleaning