码迷,mamicode.com
首页 > 编程语言 > 详细

python中的rrsplit()方法

时间:2019-09-26 11:40:29      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:count   string   方法   python   默认   列表   http   target   语法   

描述:

python rsplit() 方法通过指定分隔符对字符串进行分割并返回一个列表,默认分隔符为所有空字符,包括空格、换行(\n)、制表符(\t)等。类似于 split() 方法,只不过是从字符串最后面开始分割。

 

语法:S.rsplit([sep=None][,count=S.count(sep)])

参数:

  • sep -- 可选参数,指定的分隔符,默认为所有的空字符,包括空格、换行(\n)、制表符(\t)等。
  • count -- 可选参数,分割次数,默认为分隔符在字符串中出现的总次数

返回值:返回分割后的字符串列表。

 

实例:
  S = "this is string example....wow!!!"

  print (S.rsplit( ))    [‘this‘‘is‘‘string‘‘example....wow!!!‘]
  print (S.rsplit(‘i‘,1))  [‘this is str‘, ‘ng example....wow!!!‘]
  print (S.rsplit(‘w‘))   [‘this is string example....‘, ‘o‘, ‘!!!‘]

python中的rrsplit()方法

标签:count   string   方法   python   默认   列表   http   target   语法   

原文地址:https://www.cnblogs.com/gengshao/p/11589482.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!