YouTip LogoYouTip

Att String Isdigit

# Python2.x Python isdigit() Method [![Image 1: Python Strings](#) Python Strings](#) * * * ## Description The Python isdigit() method checks whether all characters in the string are digits. It is only valid for 0 and positive numbers. ## Syntax The syntax for the isdigit() method is: str.isdigit() ## Parameters * None. ## Return Value Returns True if the string contains only digits, otherwise returns False. ## Example The following examples demonstrate the use of the isdigit() method: ## Example #!/usr/bin/python# -*- coding: UTF-8 -*-str = "123456"# String contains only digits print(str.isdigit())str = "this is string example....wow!!!"print(str.isdigit())str = "0"print(str.isdigit())str = "-1"print(str.isdigit()) The output of the above examples is as follows: TrueFalseTrueFalse * * Python Strings](#)
← Att String MinAtt String Isalpha β†’