Python basic data type-string parameter (learning Note)

Source: Internet
Author: User

First:

Capitalize (self):

Illustration:

A1 = "Alex"

tmp = a1.capitalize ()

Print (TMP)

Output: Alex

String parameter Description: Capitalize (), capitalize the first letter of the string.    

 

Second:

Center ()

Example Description:

A1 = "Alex"

tmp = A1.center ("_")

Print (TMP)

Output: _______alex_______

String parameter Description: Center () set the total length of 20 characters, Alex is 4, set 20, then center the center, fill in front and back blank ___

 

Third:

count ()

Example Description:

A1 = "Alex is Algood"

tmp = A1.count ("Al") or TMP = A1.count ("Al", 0,4/10)

Print (TMP)

Output: The first output A1 appears two times, the second result appears 1 times/2 times

String parameter Description: Count () Number of subsequence, From left to right to find the number of Al, you can specify the number of times from the first to the first several, 0,4 set from No. 0 to fourth Al, there were several times, apparently only 1 times/10,0,10 from No. 0 to 10th, Al appeared several times, apparently appeared 2 times. (Space is also a location)

Python basic data type-string parameter (learning Note)

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.