YouTip LogoYouTip

Python3 String Isnumeric

# Python3.x Python3 isnumeric() Method [![Image 3: Python3 Strings](#) Python3 Strings](#) * * * ## Description The isnumeric() method checks whether all characters in the string are numeric characters. Numeric characters include Unicode digits, fullwidth digits (double-byte), Roman numerals, and Han (Chinese) numerals. Exponents like Β² and fractions like Β½ are also considered numeric. # s = 'Β½' s = 'u00BD' ## Syntax The syntax for the isnumeric() method is: str.isnumeric() ## Parameters * None. ## Return Value Returns True if all characters in the string are numeric characters, otherwise returns False. ## Example The following examples demonstrate the use of the isnumeric() method: ## Example #!/usr/bin/python3 str="tutorial2016" print(str.isnumeric()) str="23443434" print(str.isnumeric()) The output of the above example is: FalseTrue Unicode numerals: ## Example #!/usr/bin/python3 #s = 'Β²3455' s ='u 00B23455' print(s.isnumeric()) # s = 'Β½' s ='u 00BD' print(s.isnumeric()) a ="u 0030"#unicode for 0 print(a.isnumeric()) b ="u 00B2"#unicode for Β² print(b.isnumeric()) c ="10km2" print(c.isnumeric()) The output of the above example is: TrueTrueTrueTrueFalse * * Python3 Strings](#)
← Python3 String IstitlePython3 String Isnumeric β†’