Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to judge a string in Python

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about how to judge a string in Python. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

S.isalnum () all characters are numbers or letters

S.isalpha () all characters are letters

All characters in s.isdigit () are numbers

S.islower () all characters are lowercase

All characters in s.isupper () are uppercase

S.istitle () all words are capitalized, like headlines

S.isspace () all characters are blank characters,\ t,\ n,\ r

S1 = '1234'

S2 = '1234abcd'

S3 = 'abcd'

S4 = 'abCD'

S5 = 'ABCD'print s1.isalnum () # True

Print s1.isalpha () # False

Print s1.isdigit () # True

Print s1.islower () # False

Print s1.isspace () # False

Print s1.istitle () # False

Print s1.isupper () # False

Print s2.isalnum () # True

Print s2.isalpha () # False

Print s2.isdigit () # False

Print s2.islower () # True

Print s2.isspace () # False

Print s2.istitle () # False

Print s2.isupper () # False

Print s3.isalnum () # True

Print s3.isalpha () # True

Print s3.isdigit () # False

Print s3.islower () # True

Print s3.isspace () # False

Print s3.istitle () # False

Print s3.isupper () # False

Print s4.isalnum () # True

Print s4.isalpha () # True

Print s4.isdigit () # False

Print s4.islower () # False

Print s4.isspace () # False

Print s4.istitle () # False

Print s4.isupper () # Falseprint s5.isalnum () # True

Print s5.isalpha () # True

Print s5.isdigit () # False

Print s5.islower () # False

Print s5.isspace () # False

Print s5.istitle () # False

Print s5.isupper () # True after reading the above, do you have any further understanding of how to judge a string in Python? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report