Replace Several Items
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Wed Aug 13 13:35:11 EDT 2008
gjhames:
> What's the better way to do it?
Better is a relative term. If with better you mean "faster" (in some
circumstances), then the translate method is your friend, as you can
see its second argument are the chars to be removed. As first argument
you can use something like:
"".join(map(chr, xrange(256)))
If your strings are unicode you will need something different (a dict
with Null values for the key chars you want to remove).
Bye,
bearophile
More information about the Python-list
mailing list