📜  python代码示例中的突出显示单词

📅  最后修改于: 2022-03-11 14:45:37.095000             🧑  作者: Mango

代码示例1
from functools import reduce
from itertools import chain

text = 'left foot right foot left foot right. Feet in the day, feet at night.'
l1 = ['foot','feet']

print(reduce(lambda t, x: t.replace(*x), chain([text.lower()], ((t, colored(t,'white','on_red')) for t in l1))))