我怎样才能同时请求一个浮点数输入和一个整数?

How can I ask for a float input and an integer at the same time?

我想要求受试者先输入一个浮点数(如 3.666),然后输入一个整数。 我所做的是:

x,y = input ( " Please enter two numbers"). split () 

然后转换

x,y =[ float (x), int (y)] 

不行-有什么建议吗?

您必须将它们扫描为字符串,用 space 作为分隔符将其分隔,然后将它们转换为相应的类型。

s = raw_input("Please enter two numbers: ")
x,y = s.split(" ")
x = float(x)
y = int(y)

希望对您有所帮助:)