How can I strip first and last double quotes?

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

I want to strip double quotes from:

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

to obtain:

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


        
13条回答
  •  没有蜡笔的小新
    2020-12-02 10:49

    Starting in Python 3.9, you can use removeprefix and removesuffix:

    '"" " " ""\\1" " "" ""'.removeprefix('"').removesuffix('"')
    # '" " " ""\\1" " "" "'
    

提交回复
热议问题