【发布时间】:2016-07-26 02:07:35
【问题描述】:
我最近切换到了 Python 3,通常适用于 Python 2 的常规操作不适用于 Python 3。我已经能够修复其余部分,但我正在努力解决这个问题。我无法检查某物是什么“类型”。
raw = input("Please give me a number, string\
or decimal: ")
if type(raw) == int:
print("You entered a number")
elif type(raw) == float:
print("You entered a decimal")
elif type(raw) == str:
print("You entered a string")
else:
print("error please try again")
`
【问题讨论】:
-
应该是你输入了一个字符串 :) 对吗?
标签: python python-3.4