Python – isdigit(), isnumeric(), and isdecimal()

비슷한 숫자 판단 함수들! 누군가 아주 쉽게 테이블로 정리해 뒀어요. 감사감사 😁

Choose Between Python isdigit(), isnumeric(), and isdecimal() • datagy
Learn how to use the Python isdigit, isnumeric, and isdecimal methods to check whether or not a string is a number and their differences.

  • 그냥 10진수 숫자를 뽑아내려면 isdecimal() 로 확인하면 되고,
  • 분수나 승수 같은 것을 표현한 숫자 문자열도 확인하려면 isdigit()
  • 예전 로마자 숫자 등등의 숫자와 연관된 문자열까지 확인하려면 isnumeric()

표로 정리해 두셔서 아주 좋은 글, 직접 들어가서 확인하시면 저자가 좋아하시겠네요 🙂

String Type Example Python .isdecimal() Python .isdigit() Python .isnumeric()
Base 10 Numbers '0123' True True True
Fractions and Superscripts '⅔', '2²' False True True
Roman Numerals 'ↁ' False False True