Is there any way to replace multiple characters in a string at once, so that instead of doing:
"foo_faa:fee,fii".replace("_", "").replace(":", "").replace(",", "")
just something like (with str.replace())
"foo_faa:fee,fii".replace(["_", ":", ","], "")
>Solution :
An option that requires no looping or regular expressions is translate:
>>> "foo_faa:fee,fii".translate(str.maketrans('', '', "_:,"))
"foofaafeefii"
Note that for Python 2, the API is slightly different.