Python string-Class substring lookup function

Source: Internet
Author: User

The Python string class has a useful function that is handy for operations related to finding Python string type Object substrings, with the following APIs:

|   Find (...)|     S.find (Sub [, Start [, end]]), int|     |     inch  is found,|      is contained within S[start:end]. Optional|      and inch slice notation.|     |     Return-1 On Failure

Assume that S is a string object, call the Find function and pass in the substring of a substring or substring (that is, a slice of a substring from start to end) as a parameter.

The return value is of type int, and if S contains an incoming parameter sub, returns the index of the substring (substring) in the parent string (S), and returns 1 for the lookup index failure if the substring passed in as a parameter is not included.

Python string-Class substring lookup function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.