1.把字符串中的对应字符剔除 "abc".translate(None, 'b') 2.translate方法也可以把对应的字符转化 from string import maketrans "abc".translate(maketrans('b', '2'))