Python Learning starter Tutorial, String function extensions

Source: Internet
Author: User

Because the user reflects, in the basic article on the string function is too little to explain, so write an article in detail about the commonly used string functions. This article is about: Programmers take you 10 days to get started Python, play computer software development (iii) the elaboration and expansion of string functions.

If you want to learn and participate in this tutorial to improve and write. Please reply to the relevant questions in the discussion area below. Together to improve the writing of this article tutorial.

Python string common functions.

To declare a string variable:

str = ' focus on doing all-stack siege Lion, write code to read, love the whole stack, more love life. ’

All of the following string function functions are performed on the variable str:

      1. To find the string length:


        1. function use:

          Operation Result:

        2. It is worth noting that the length of a Chinese character is 3

      2. Case-handling related functions:

        1. Code:

          Operation Result:

        2. Uppercase and lowercase swaps and first-letter capitalization functions

          Function:


Operation Result:

3. String Lookup function:

1. Search for the specified string, no return-1:

function display:

Operation Result:

4. String substitution function:

Function Demo:

Operation Result:

5. Remove the spaces on both sides of the string:

Function Demo:

Run results

6. Split string:

Function Description:


Operation Result:

The usual functions of the Python string are described here first. There are other related functions that must be updated later.

Learn the full stack technology please follow and add QQ Group: 538742639

Next: Python Development Practical Tutorials (8)-Submit data to Web pages

Python Learning starter Tutorial, String function extensions

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.