Python3----conversion case (upper lower capitalize and title)

Source: Internet
Author: User

Like other languages, Python provides a way to convert the casing to a String object: Upper () and lower (). More than that, Python also provides us with the initials, the rest of the lowercase capitalize () method, and the first uppercase of all words, and the remaining lowercase title () method. The function is relatively simple, see the following example:

1s ='HEllo PYthon'2 Print(S.upper ())3 Print(S.lower ())4 Print(S.capitalize ())5 Print(S.title ())6 7 Results:8 9 HELLO PYTHONTen Hello python One Hello python AHello Python

To determine the case

Python provides the isupper (), Islower (), and Istitle () methods used to determine the case of a string. Note that the following are:
1. The Iscapitalize () method is not provided, which we will implement ourselves, and why Python is not implemented for us is unknown.
2. If you use Isupper (), Islower (), Istitle () for an empty string, the returned result is false.

1 Print('A'. Isupper ())#True2 Print('A'. Islower ())#False3 Print('Python is good'. Istitle ())#True4 #print ' Dont do that! '. Iscapitalize () #错误, there is no Iscapitalize () method

Python3----conversion case (upper lower capitalize and title)

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.