分析字符串,整数或浮点数的输入时输出不正确

时间:2015-03-18 15:08:36

标签: python

x=input('Enter input:')
print (type(x))
if type(x)==type(""):
    print ("It is a string")
elif type(x)==type(1):
    print ("It is an integer")
elif type(x)==type(1.0):
    print ("It is a floating point")
else:
    print ("It is other than integer,floating point and string")

每次运行此程序时,<class 'str'>'It is a string'都会作为输出。

0 个答案:

没有答案