【发布时间】:2021-02-14 23:46:38
【问题描述】:
我想知道在使用if else语句并检测输入的数据是哪种数据类型时如何使python程序工作。
这是我根据我的知识输入的代码(对不起,我是新手):
FullName = input("Enter your Full Name: ")
data = input("Enter a data: ")
if type(eval(data)) == float and int:
if type(eval(data)) == float:
print("Hello,", FullName + ". Your inputted data", data, "is a type of Float!")
else:
print("Hello,", FullName + ". Your inputted data", data, "is a type of Integer!")
else:
print("Hello,", FullName + ". Your inputted data", data, "is a type of String!")
如果您能纠正我的工作,请随意,我将不胜感激。谢谢!
【问题讨论】:
标签: python-3.x types nested-if