mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
No need to define raw_input(), input() does the same.
This commit is contained in:
parent
ed44a1a68b
commit
e9af284e99
2 changed files with 3 additions and 21 deletions
|
|
@ -85,15 +85,9 @@ entered, but allows the user to interrupt the program (using :kbd:`Control-C` or
|
|||
whatever the operating system supports); note that a user-generated interruption
|
||||
is signalled by raising the :exc:`KeyboardInterrupt` exception. ::
|
||||
|
||||
>>> def raw_input(prompt):
|
||||
... import sys
|
||||
... sys.stdout.write(prompt)
|
||||
... sys.stdout.flush()
|
||||
... return sys.stdin.readline()
|
||||
...
|
||||
>>> while True:
|
||||
... try:
|
||||
... x = int(raw_input("Please enter a number: "))
|
||||
... x = int(input("Please enter a number: "))
|
||||
... break
|
||||
... except ValueError:
|
||||
... print "Oops! That was no valid number. Try again..."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue