How can I strip first and last double quotes?

后端 未结 13 1279
抹茶落季
抹茶落季 2020-12-02 10:14

I want to strip double quotes from:

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

to obtain:

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


        
13条回答
  •  眼角桃花
    2020-12-02 10:59

    in your example you could use strip but you have to provide the space

    string = '"" " " ""\\1" " "" ""'
    string.strip('" ')  # output '\\1'
    

    note the \' in the output is the standard python quotes for string output

    the value of your variable is '\\1'

提交回复
热议问题