Removing all occurences of a character from a string.

Justin Shaw wyojustin at hotmail.com
Tue Sep 24 23:07:15 EDT 2002


> How can I remove the single quotes so that "'Hello World'" becomes "Hello
World"?

Try this one:

>>> s = "'Hello World'"
>>> print s.replace("'", "")
Hello World
>>>

Justin

> I have a string, say "'Hello World'", where Hello World is in single
> quotes(i.e., 'Hello World'). How can I remove the single quotes so that
> "'Hello World'" becomes "Hello World"?
> Thanks
> Sean Ross
>
>





More information about the Python-list mailing list