从STDIN Python读入文本

时间:2015-10-09 05:27:11

标签: python stdin numeric

我想知道如何从STDIN中读取它并将其存储到两个数字变量中。谢谢

10
20

-Rik

1 个答案:

答案 0 :(得分:1)

在python2.7 +中:

x=int(raw_input()) #Terminal will stall to allow user to input the first number
y=int(raw_input()) #This will wait for the second number to be inputted

在python3中:

x=int(input()) #Terminal will stall to allow user to input the first number
y=int(input()) #This will wait for the second number to be inputted