在python中从用户那里获取多个输入 [英] Taking multiple inputs from user in python
本文介绍了在python中从用户那里获取多个输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何在 python 2.5
中获取用户的单个输入:
I know how to take a single input from user in python 2.5
:
raw_input("enter 1st number")
这会打开一个输入屏幕并输入第一个数字.如果我想再次输入,我需要重复相同的命令并在另一个对话框中打开.如何在打开的同一个对话框中同时输入两个或多个输入:
This opens up one input screen and takes in the first number. If I want to take a second input I need to repeat the same command and that opens up in another dialogue box. How can I take two or more inputs together in the same dialogue box that opens such that:
Enter 1st number:................
enter second number:.............
推荐答案
这可能很有用:
a,b=map(int,raw_input().split())
然后您可以分别使用a"和b".
You can then use 'a' and 'b' separately.
这篇关于在python中从用户那里获取多个输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文