Deleting characters from a string

Skip Montanaro skip at mojam.com
Sun Jun 6 15:57:29 EDT 1999


> What I would really like to be able to do is write:
> 
>   host = string.translate(host, None, ' "')
> 
> Am I missing a more elegant solution?

Probably less elegant, but you can use string.replace.  You'll have to
call it twice to get the spaces and the double quotes:

    host = string.replace(string.replace(host, '"', ""), " ", "")

-- 
Skip Montanaro	| Mojam: "Uniting the World of Music"
http://www.mojam.com/
skip at mojam.com  | Musi-Cal: http://www.musi-cal.com/
518-372-5583




More information about the Python-list mailing list