python How can I strip first and last double quotes


Question

I want to strip double quotes from

string = '"" " " ""\\1" " "" ""'

to become

string = '" " " ""\\1" " "" "'

I tried to use rstrip, lstrip and strip('[^\"]|[\"$]') but it did not work.

How can I do this? Thank you for helping me.

1
92
3/25/2016 11:45:53 PM

If the quotes you want to strip are always going to be "first and last" as you said, then you could simply use:

string = string[1:-1]

170
6/21/2010 2:15:56 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon