好的,这是示例:
data = ['This', 'is', 'a', 'test', 'of', 'the', 'list']
replaceText = 'test'
replaceData =['new', 'test']
我做了 data.replace(replaceText, replaceData) 但它不起作用。如何用字符串列表替换字符串列表中的字符串?任何帮助将不胜感激。
编辑:确切的条件是替换或拆分包含“s”的单词,所以我在其中放置了一个循环。所以最终结果将打印 data = ['Thi', 'i', 'a', 'te','t', 'of', 'the', 'li','t']