Original English help files:
input
([prompt])
If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, EOFError
is raised. Example:
>>> s = input('--> ') --> Monty Python's Flying Circus >>> s "Monty Python's Flying Circus"
If the readline
module was loaded, then input()
will use it to provide elaborate line editing and history features.
-------- (I am dividing line) --------
Chinese explanation:
input
([prompt])
If prompt parameter exists, it is written to standard output, rather than with trailing break. The function then reads a line from the input, which was converted to a string (removing the trailing newline), and returns the row.
When reading the EOF, throws EOFError
. example:
>>> s = input('--> ') --> Monty Python's Flying Circus >>> s "Monty Python's Flying Circus"
About EOFError:
exception EOFError
Raised when the input() function hits an end-of-file condition (EOF) without reading any data. (N.B.: the io.IOBase.read() and io.IOBase.readline() methods return an empty string when they hit EOF.)
() Initiated at the end of the condition (EOF) function is reached when the input file without any read data. (Note: io.iobase.read () and io.iobase.readline () method returns an empty string when reaching EOF.)
If the read-readline module input()
will use it to provide fine-line editing and history features.
Example:
>>> input() s 's' >>> a = input("please input str") please input str99 >>> a '99' >>> a = input("please input str\n") please input str 100 >>> a '100' >>>
------- (I am dividing line) --------
Note: The difference between input function in Python 2.x and Python 3.x versions:
So in Python 2.x it is common to raw_input ();
Original Address: https: //blog.csdn.net/suibianshen2012/article/details/51378948
-------- (I am dividing line) --------
reference:
1. Python 3.7.2 documentation
2. RUNOOB.COM:
https://www.runoob.com/python/python-func-input.html
https://www.runoob.com/python3/python3-func-input.html
https://www.runoob.com/w3cnote/python2-python3-raw_input-and-input.html
3. https://blog.csdn.net/suibianshen2012/article/details/51378948
Remarks:
Initial modified: September 21, 2019 22:41:17
Environment: Windows 7 / Python 3.7.2