안녕하세요. BlockDMask 입니다. Show 1-1) isdigit 설명isdigit은 string 클래스에 있는 메서드 입니다. str.isdigit() 문자열이 '숫자'로만 이루어져있는지 확인하는 함수 입니다. 문자가 '단 하나'라도 있다면 False를 반환하고, 사용법 두가지 방법 다 사용이 가능합니다. str.isdigit() 은 음수를 뜻하는 '-', 소수점을 뜻하는 '.' 이것들을 숫자가 아닌 문자로 판단을
하기 때문에 정리하자면 "오직 0을 포함한 양수형 정수로만 이루어진 문자열"만 isdigit에서 True가 나올 수 있습니다. 1-2) 파이썬 isdigit 예제
결과에서 보시면 str.isdigit() 함수는 오직 0을 포함한 양수로 이루어진 숫자와 지수만 True로 반환하는 것을 볼 수 있습니다.
오늘은 이렇게 isdigit 에 대해서 알아보았습니다. 감사합니다. ❮ String Methods ExampleCheck if all the characters in the text are digits: txt = "50800" x = txt.isdigit() print(x) Try it Yourself » Definition and UsageThe Exponents, like ², are also considered to be a digit. SyntaxParameter ValuesNo parameters. More ExamplesExampleCheck if all the characters in the text are digits: a = "\u0030" #unicode for 0 print(a.isdigit()) Try it Yourself » ❮ String Methods 파이썬에서 문자열이 숫자로만 구성되어있는지 확인할 때 String의 Output: 3. 음수 또는 소수점에 대한 isdigit() 결과
Output: 4. 유니코드에 대한 isdigit() 결과유니코드는
Output:
codechachaCopyright ©2019 codechacha |