Created
June 3, 2017 18:06
-
-
Save nattybear/b9dbfbb54b159a6e1b432d559a9bd1a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 글자로만 구성된 문자열 | |
| str1 = "hello" | |
| # 숫자가 포함된 문자열 | |
| str2 = "hello123" | |
| # isdigit()는 문자열 객체의 메소드이다. | |
| # 문자열에 숫자가 포함되어 있는지 아닌지를 | |
| # 검사해서 숫자가 있으면 참을 리턴하고 | |
| # 숫자가 없으면 거짓을 리턴한다. | |
| a = str1.isdigit() | |
| b = str2.isdigit() | |
| print(a) # False | |
| print(b) # True |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
메소드에
is라는 단어가 들어가면 참거짓Is he good?과 같이is가 앞에 오면 물어보는 문장이 된다.is가 들어가면 참거짓을 리턴하는 함수일 가능성이 크다.hello문자열에는 숫자가 하나도 없으므로isdigit의 결과는 거짓이 된다.hello123문자열에는 숫자가 포함되어 있으므로 참을 리턴한다.