quick question

Daniel Bickett dbickett at gmail.com
Tue Mar 8 01:46:25 CET 2005


If you simply wanted to get rid of quotes entirely, you could use:

"\"Hello!\"".replace( "\"" , "" )

However, since you only want the beginning and ending quotes removed:

>>> string = "\"If thou wert my fool, nuncle...\""
>>> print string
"If thou wert my fool, nuncle..."

>>> if string.startswith("\""): string = string[1:]
>>> print string
If thou wert my fool, nuncle..."

>>> if string.endswith("\""): string = string[:-1]
>>> print string
If thou wert my fool, nuncle...

Does this suffice?

-- 
Daniel Bickett
dbickett at gmail.com
http://heureusement.org/



More information about the Python-list mailing list