strip()方法

描述

strip() 方法用于删除字符串头部和尾部指定的字符,默认字符为所有空字符,包括空格、换行(\n)、制表符(\t)等。

 

strip() 方法语法:

S.strip([chars])

参数

  • chars -- 可选参数,要删除的指定字符,默认字符为所有空字符,包括空格、换行(\n)、制表符(\t)等。

返回值

返回删除字符串头部和尾部指定的字符后生成的新的字符串。

实例

以下实例展示了 strip() 方法的使用方法:

S = "*****this is string example....wow!!!*****"
print(S.strip("*"))

# 结果为
# this is string example....wow!!!

 

相关文章:

  • 2021-06-08
  • 2021-05-25
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-13
  • 2021-10-11
  • 2021-07-30
  • 2021-07-10
  • 2022-12-23
相关资源
相似解决方案