从标准Python读入文本

2024-04-25 04:24:39 发布

您现在位置:Python中文网/ 问答频道 /正文

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

10
20

-里克


Tags: stdin数字
1条回答
网友
1楼 · 发布于 2024-04-25 04:24:39

在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

相关问题 更多 >