How to judge a string in Python
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.