STR string capitalize () method

Source: Internet
Author: User

Describe

The Python count () method is used to count the occurrences of a character in a string. The optional parameters are the start and end positions of the string search.

Grammar

Count () method syntax:

Str.  Count(Sub, start=0,end=len(string))  
Parameters
    • Sub--The substring of the search
    • Start--the location where the string starts searching. The default is the first character, and the first character index value is 0.
    • End--the location of the ending search in the string. The index of the first character in a character is 0. The default is the last position of the string.
return value

The method returns the number of occurrences of a substring in a string.

Instance

The following example shows an instance of the Count () method:

me ="I ' m change, it's a vegetable bag."Print("me.count (' E '):", Me.count ("e"))Print("me.count (' e ', 2,7):", Me.count ("e", 2,7))Print("me.count (' e ', 7,-1):", Me.count ("a", 7,-1))

The result of the above example output is as follows:

Me.count ('e'):  4me.count ('e', 2,7):  0me.count ('e', 7,-1):  3

STR string capitalize () method

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.