Python:我怎样才能使这个工作?

时间:2015-03-01 00:09:29

标签: python python-2.7

我该如何做到这一点?

number = int(raw_input("Number: "))
if number != !!!!!!!!NUMBER TYPE IS NOT AN INT TYPEEE!!!!!!!!!
    print "NO!"
else
    print "YES!"

谢谢! :)

2 个答案:

答案 0 :(得分:2)

try:
    num = int(raw_input("Number: "))
    print("Yes!")
except ValueError:
    print("No!")

答案 1 :(得分:0)

number = raw_input("Number: ")

if not number.isdigit():
    print "NO!"
else:
    print "YES!"