The third function parses --python learning summary

.str string type (II)

1. isalpha determined whether the target string contains only the letter

  Expressions str.isalpha () ==> bool

  Example:

. 1 A = ' Alex ' 
2 V = a.isalpha ()
 . 3  Print (V) 
# output
# True

  Source:

1     def isalpha(self, *args, **kwargs): # real signature unknown
2         """
3         Return True if the string is an alphabetic string, False otherwise.
4         
5         A string is alphabetic if all characters in the string are alphabetic and there
6         is at least one character in the string.
7         """
Source

 

2.  isdecimal

     isdigit are used to determine whether the target string is a number, the following can be judged not only plain text, but also complex symbols is determined.

  Expressions str.isdecimal () ==> bool

               str.isdigit()  ==>  bool

  Example:

1 a = ''
2 b = a.isdecimal()
3 c = a.isdigit()
4 print(b,c)
# 输出
# false true

  Source:

1     def isdecimal(self, *args, **kwargs): # real signature unknown
2         """
3         Return True if the string is a decimal string, False otherwise.
4         
5         A string is a decimal string if all characters in the string are decimal and
6         there is at least one character in the string.
7         """
isdecimal
1     def isdigit(self, *args, **kwargs): # real signature unknown
2         """
3         Return True if the string is a digit string, False otherwise.
4         
5         A string is a digit string if all characters in the string are digits and there
6         is at least one character in the string.
7         """
isdigit

 

3.  

 

Guess you like

Origin www.cnblogs.com/zhuqt-2008/p/11511912.html