Keyboard input

Keyboard input

Python provides a build-in function called raw_input (in version 2.x) that gets input from the keyboard. In Python 3.x we use input(). When this function is called, the program stops and waits for the user to type something. When the user presses Return or Enter, the program resumes and input() returns what the user typed as a string.

                       

Before calling input(), it is a good idea to print a prompt telling the user what to input. input() takes a prompt as an argument:

 

 

from Thinking in Python

 

posted @ 2014-05-01 15:28  平静缓和用胸音说爱  阅读(334)  评论(0编辑  收藏  举报