In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the example introduction of rindex () method in Python". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the example introduction of the rindex () method in Python".
Description
The Python rindex () method returns the index position where the substring last appeared in the string, which is the same as the rfind () method, except that an exception is reported if the substring is not in the string.
Grammar
The syntax of the rindex () method:
S.rindex (sub [, start=0 [, end=len (S)]]) parameters
Sub-- specifies the substring to retrieve
S-parent string
Start-optional parameter, the location where to start the search. Default is 0. (can be specified separately)
End-optional parameter to end the search position, which defaults to the length of the string. (cannot be specified separately)
Return value
Returns the index position of the last occurrence of the substring in the string, and an exception is reported if there is no match.
Example
The following example shows the use of the rindex () method:
#! / usr/bin/python3S1 = "this is really a string example.wowning examples!" S2 = "is" print (S1.rindex (S2)) print (S1.rindex (S2mem10))
The output of the above example is as follows:
five
Traceback (most recent call last):
File "test.py", line 6, in
Print (str1.rindex (str2,10))
ValueError:substring not found
At this point, I believe you have a deeper understanding of the "example introduction of the rindex () method in Python". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.