Python rpartition() 方法

Python 教程 · 2019-02-02 17:11:38

描述

rpartition() 方法类似于 partition() 方法,只是该方法是从目标字符串的末尾也就是右边开始搜索分割符。。

如果字符串包含指定的分隔符,则返回一个3元的元组,第一个为分隔符左边的子串,第二个为分隔符本身,第三个为分隔符右边的子串。

语法

rpartition()方法语法:

str.rpartition(str)

参数

str : 指定的分隔符。

返回值

返回一个3元的元组,第一个为分隔符左边的子串,第二个为分隔符本身,第三个为分隔符右边的子串。

实例

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

实例(Python 2.0+)

#!/usr/bin/python str = "www.codercto.com" print str.rpartition(".")

输出结果为:

('www.codercto', '.', 'com')

点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

Beginning XSLT 2.0

Beginning XSLT 2.0

Jeni Tennison / Apress / 2005-07-22 / USD 49.99

This is an updated revision of Tennison's "Beginning XSLT", updated for the new revision of the XSLT standard. XSLT is a technology used to transform an XML document with one structure into another ......一起来看看 《Beginning XSLT 2.0》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具