Simple example of Python string case-sensitivity conversion

Source: Internet
Author: User
The following is a simple example of Python string case-sensitivity conversion. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at the following small series to bring you a simple example of Python string case-sensitivity conversion. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at it with Xiaobian.

① All letters are converted to uppercase letters.

#-*-Coding: UTF-8 -*-

If _ name _ = "_ main __":
A = 'Hello, world! '
Print (a. upper () output:


HELLO, WORLD!

② All letters are converted to lowercase letters

#-*-Coding: UTF-8 -*-

If _ name _ = "_ main __":
A = 'Hello, WORLD! '
Print (a. lower () output:


Hello, world!

③ The initial character is converted to uppercase and the remaining characters are converted to lowercase letters.

#-*-Coding: UTF-8 -*-

If _ name _ = "_ main __":
A = 'Hello, WORLD! '
Print (a. capitalize () output:


Hello, world!


④ The first letter of all words is converted into uppercase letters, and the other words are converted into lowercase letters.

#-*-Coding: UTF-8 -*-

If _ name _ = "_ main __":
A = 'Hello, WORLD! '
Print (a. title () output:


Hello, World!

⑤ Judge that all letters are in uppercase

#-*-Coding: UTF-8 -*-

If _ name _ = "_ main __":
A = 'Hello, WORLD! '
Print (a. isupper ())

B = 'Hello, world! '
Print (B. isupper () output:


True
False


6. all letters are lowercase.

#-*-Coding: UTF-8 -*-

If _ name _ = "_ main __":
A = 'Hello, WORLD! '
Print (a. islower ())

B = 'Hello, world! '
Print (B. islower () output:


False
True


7. determine that the first letter of all words is uppercase.

#-*-Coding: UTF-8 -*-

If _ name _ = "_ main __":
A = 'Hello, WORLD! '
Print (a. istitle ())

B = 'Hello, world! '
Print (B. istitle ())

C = 'Hello, World! '
Print (c. istitle () output:


False
False
True

The simple example of the above Python string case-sensitivity conversion is all the content that I have shared with you. I hope to give you a reference and support for PHP.

For more articles about simple Python string case-sensitivity conversion, refer to PHP!

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.