python中的strip函数

本文介绍了Python中的strip()、lstrip()和rstrip()三个字符串处理函数,详细解析了它们的功能和用法,帮助理解如何在Python中进行字符串边缘处理。
摘要由CSDN通过智能技术生成

python有strip()、lstrip()、rstrip()这样的三个函数,官方文档是这样解释的:

str. strip ( [ chars ] )

Return a copy of the string with the leading and trailing characters removed. Thechars argument is a string specifying the set of characters to be removed. If omitted orNone, thechars argument defaults to removing whitespace. Thechars argument is not a prefix or suffix; rather, all combinations of its values are stripped:

>>> '   spacious   '.strip()
'spacious'
>>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值