22智能在线
新记
python strip怎样去引号
如题所述
举报该文章
相关建议 2016-11-22
python
字符串
中的strip方法只能在首尾去除参数中指定的字符,不传参数默认是去除首尾的空白符
' head tail '.strip()#去除首尾空白符
' "head tail "'.strip('"')#去除双引号
如果要去除所有的引号,得用字符串的replace方法
' head tail '.replace(' ','')#去除所有空白符
'"head" and "tail"'.replace('"','')#去除所有的双引号
温馨提示:内容为网友见解,仅供参考
当前网址:
https://22.t2y.org/zz/cits6iicii2cxtxxf2t.html
其他看法
第1个回答 推荐于2018-03-02
要加转义
>>> a="\"abc\""
>>> print a
"abc"
>>> print a.strip("\"")
abc
本回答被网友采纳
相似回答
大家正在搜
相关问题
python strip怎么去除空格
python strip函数怎么调用
python怎么不用strip()就去掉首末的字母啊?
python高手看过来,关于strip()函数会去掉首尾的指...
python strip()是什么意思?具体看我例子
python 4-6 如何去掉字符串中不需要的字符strip...
python当中strip()是起什么作用的?举例说明一下,...
python 利用切片操作,实现一个trim()函数,去除字...