Python basic syntax--string built-in functionality

Source: Internet
Author: User
Tags first string

1.capitalize---The first letter to uppercase, if the first child is already uppercase or output the initial capitalization result

Example:

2.casefold---Uppercase to lowercase for all content

Example:

3.center----content Centered

Example: PS This example outputs 20 characters (containing the string "admin occupies 5 characters") and centers the string "admin"

4.count---The number of occurrences of a statistic, returning a positive integer type

Example: PS result 1: is a statistic specified from the 4th string to the 9th string (the string is calculated starting from position 0)

5.encode---code modification

Example:

6.endswith--Determines whether to return a bool value at the end of the specified string

Example: PS result 1: is specified from the 3rd string to the 5th string to determine whether the end character = "or", so returns a Boolean false (the string is calculated from position 0)

  

7.expandtabs---Converts the tab (\ T) in a string to a space, the default number of spaces Tabsize is 8 characters

Example: Conversion tab (\ t) is replaced by a space with a default of 8 spaces. Expandtabs (20) Specify the number of spaces

8.find---Find the location of the first string to match (you can also specify a lookup range, where the position is calculated from 0)

Example:

9.format---String formatting (equivalent to%s)

Example:

To be continued ......... ...............

Python basic syntax--string built-in functionality

Related Article

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.