Python determines what string functions are.
Editor to share with you what the python judgment string function is, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Isalpha determines whether all characters in a string are letters.
# a.isalpha () # determines whether all characters in the string are letters s = 'jack ma\ n' S1 = 'jack ma's2 =' Jack's3 = 'jack25's4 =''# # empty string also returns Falses_new = s.isalpha () s1_new = s1.isalpha () s2_new = s2.isalpha () s3_new = s3.isalpha () s4_new = s4.isalpha () print (s_new) print (s1_ New) print (s2_new) print (s3_new) print (s4_new) output: FalseFalseTrueFalseFalse
2. Isdigit determines whether all characters of a string are integers.
# a.isdigit () # determines whether all characters in the string are integers n = '24roomm =' 24.3'result = n.isdigit () result1 = m.isdigit () print (result) print (result1) output: TrueFalse
3. Isalnum determines whether all characters in a string are letters or numbers.
# a.isalnum () # determine whether all characters in the string are alphanumeric s = 'jack ma\ n' S1 = 'jack ma's2 =' jack's3 = 'jack25's_new = s.isalnum () s1_new = s1.isalnum () s2_new = s2.isalnum () s3_new = s3.isalnum () print (s_new) print (s1_new) print (s2_new) print (s3_new) output: FalseFalseTrueTrue
4. Isspace determines whether all characters in the string are blank characters.
# a.isspace () # determines whether all characters in the string are blank characters S1 ='S2 ='S3 ='\ r's4 ='\ n's1_new = s1.isspace () s2_new = s2.isspace () s3_new = s3.isspace () s4_new = s4.isspace () print (s1_new) print (s2_new) print (s3_new) print (s4_new) output: python judgment above FalseTrueTrueTrue What are string functions? all the contents of this article Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!