python

[Python] isdigit(), isalpha()함수

딸기케잌🍓 2020. 5. 25. 22:34

isalpha 함수

문자열이 문자인지 아닌지를 True, False로 리턴해준다.

 

isdigit함수

문자열이 숫자인지 아닌지를 True, False로 리턴해준다.

 

 

코드

1
2
3
4
5
6
7
8
9
10
11
12
    test = '123'
    test2 = 'imstring'
    test3 = 'three'
 
    ischar = test.isdigit()
    isdigit = test.isalpha()
 
    ischar2 = test2.isdigit()
    isdigit2 = test2.isalpha()
 
    ischar3 = test3.isdigit()
    isdigit3 = test3.isalpha()
cs

 

 

실행결과

True
False

False
True

False
True