Python core programming chapter sixth exercises

Source: Internet
Author: User

Some methods of string:

String.Split (str) slices a string with the str delimiter (the default is an empty compartment), and if NUM has a specified value, only the NUM substring is delimited.

String.count (str) calculates the number of STR occurrences in a string.

String.find (STR) detects if STR exists in a string, there is a return index value, and 1 is not present.

String.casefold () Change all string characters to lowercase

String.capitalize (str) Change the first character of a string to uppercase

>>> C = ' Hello world! ' >>> c.split () [' Hello ', ' world! '] >>> c.split (' o ') [' Hell ', ' w ', ' rld! ']

>>> C.casefold ()

' Hello world! ' >>> c.capitalize () ' Hello world! ' >>> c.count (' l ') 3>>> c.find (' l ') 2

Python core programming chapter sixth exercises

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.