如何去掉第一个和最后一个双引号? [英] How can I strip first and last double quotes?

查看:51
本文介绍了如何去掉第一个和最后一个双引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想去掉双引号:

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

获得:

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

我尝试使用 rstriplstripstrip('[^\"]|[\"$]') 但它没有用.

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

我该怎么做?

推荐答案

如果您想删除的引号总是如您所说的第一个和最后一个",那么您可以简单地使用:

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]

这篇关于如何去掉第一个和最后一个双引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆