"Basic Python Tutorial" chapter III: Using Strings

Source: Internet
Author: User

  1. The Find method can find substrings in a longer string. It returns the leftmost index of the location where the substring is located. Returns 1 if not found
  2. The Join method is used to add elements to the queue, and the queue element that needs to be added must be a string
    ' + '. Join (SEQ)

  3. Lower method returns the lowercase master of a string
  4. The Replace method returns a string after all occurrences of a string have been replaced
    ' This is a test '. Replace ('is''ezz')

  5. The split method is used to split a string into a sequence. If no delimiter is provided, the program will use all spaces as separators
  6. The Strip method returns a string that removes spaces on both sides. You can also specify the characters that need to be removed, and list them as parameters
  7. The Translate method can make multiple substitutions at the same time, using the Maketrans function before using the translate transformation. The Maketrans function accepts two parameters: two equal-length strings, which indicate that each character in the first string is replaced with a character in the same position in the second string
     from Import maketrans>>> table = Maketrans ('cs'kz')

    After you create the table, you can use it as a parameter to the Translate method

    ' This was an incredible test '. Translate (table)

"Basic Python Tutorial" chapter III: Using Strings

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.