Python-AttributeError:“ str”对象没有属性“ isDigit”

Ada*_*ths 1 python attributes python-2.7

这是我的代码

input = raw_input("Please enter a number")  
print input.isDigit()
Run Code Online (Sandbox Code Playgroud)

当我在解释器中输入7时,它会引发错误:

AttributeError: 'str' object has no attribute 'isDigit'
Run Code Online (Sandbox Code Playgroud)

这是没有意义的,因为isDigit它是内置函数,并且用于字符串。我正在使用python 2.7并且正在使用JetBrains Pycharm,所以它可能是我正在使用的IDE吗?

Avi*_*Raj 5

D必须使用小写字母小写字母)。

print input.isdigit()
Run Code Online (Sandbox Code Playgroud)

并且不要将内置关键字用作变量名。

>>> inp = raw_input("Please enter a number: ")
Please enter a number: 5
>>> print inp.isdigit()
True
Run Code Online (Sandbox Code Playgroud)