我是python的新手,我希望使用python用不同的子字符串替换相同的子字符串。我已经尝试过python的.replace()函数,但是它用新的子字符串替换了所有出现的情况。string = "I是学生as well as “在这里,我想将子字符串"as”替换为"xas“和"yas”,向子字符串中添加额外的字符。
我有一个句子列表,如下所示: sentences = ["I am learning to code", "coding seems to be intresting in python", "howto code in python", "practicing how to code is the key"] 现在,我希望使用字典及其替代项替换这个句子列表中的几个子字符串。()])
for sentence in sentences] 但只有