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)