[Tutor] Remove specific chars from a string

Alan Gauld alan.gauld at btinternet.com
Mon Apr 14 21:00:20 CEST 2008


"Malcolm Greene" <python at bdurham.com> wrote

> What is the Pythonic way to remove specific chars from a string? The
> .translate( table[, deletechars]) method seems the most 'politically
> correct' and also the most complicated.

Assuming you have lots of different characters and not just
one to remove, then: either translate()  or

> 3. Use a regular expression

HTH,

Alan G. 




More information about the Tutor mailing list