Python 2.7简单程序

时间:2013-03-31 19:12:10

标签: python python-2.7

对于作业,我们必须使用Python 2.7开发一个简单的程序,从用户收集信息并使用它做出决定。我的问题是如何向计算机输入一条消息,告诉它一旦用户输入这些信息可以做到这一点,等等...... 由于python逐行执行此操作,一旦用户输入了所有信息,您将如何告诉它生成结果。

非常感谢

2 个答案:

答案 0 :(得分:1)

你基本上是在学习如何学习用Python编程。 互联网上有很多教程。 也许这会有所帮助:http://hetland.org/writing/instant-python.html

答案 1 :(得分:1)

这样的东西?

user = input('Which option? ')
# when the user presses 'Enter', the next line is
# automatically executed
if int(user) == 1: option1() # this is a function
elif int(user) == 2: option2() # another function
# etc.