How to read two inputs separated by space in a single line?

前端 未结 11 548
天涯浪人
天涯浪人 2020-12-23 22:23

I want to read two input values. First value should be an integer and the second value should be a float.

I saw Read two variables in a single line with Python, but

11条回答
  •  遥遥无期
    2020-12-23 23:06

    Like this:

    In [20]: a,b = raw_input().split()
    12 12.2
    
    In [21]: a = int(a)
    Out[21]: 12
    
    In [22]: b = float(b)
    Out[22]: 12.2
    

    You can't do this in a one-liner (or at least not without some super duper extra hackz0r skills -- or semicolons), but python is not made for one-liners.

提交回复
热议问题