Want to start () replaced with replace, but to deal with more characters to write code is not clean
a='fs233*bb>>c##ad'
a.replace('*','-').replace('>','-').replace('#','-')
print(a)
fs233bbcad
You can only replace a character string or
later discovered can be used re.sub () perfect solution
import re
a='fs233*bb>>c##ad'
re.sub(r'[\*>#]','-',a)
print(a)
fs233bbcad
The re.sub first parameter () is a pattern, a regular expression, so the example [*> #] represents [any character], i.e. the replacement of a *> # is -. Also learn more please use regular expressions