📅  最后修改于: 2022-03-11 14:46:42.809000             🧑  作者: Mango
def ReplaceAllInList(list, lookupvalue, replacewith):
return [(replacewith if v == lookupvalue else v) for v in list]
a = ['aaa', 'bb', 'bb']
a = ReplaceAllInList(list= a, lookupvalue= 'bb', replacewith= 'cc')
print(a) # output --> ['aaa', 'cc', 'cc']