Python uses raw_input to read the input value.
This article describes the usage of raw_input in python in detail. Using raw_input can easily read data from the consortium console. The usage example is as follows:
1. input string
#13222319810101****nID = ''while 1: nID = raw_input("Input your id plz") if len(nID) != len("13222319810101****"): print 'wring length of id,input again' else: break print 'your id is %s' % (nID)
2. Input an integer
nAge = int(raw_input("input your age plz:\n"))if nAge > 0 and nAge < 120: print 'thanks!'else: print 'bad age'print 'your age is %d\n' % nAge
3. Input floating point type
fWeight = 0.0fWeight = float(raw_input("input your weight\n"))print 'your weight is %f' % fWeight
4. Enter hexadecimal data
nHex = int(raw_input('input hex value(like 0x20):\n'),16)print 'nHex = %x,nOct = %d\n' %(nHex,nHex)
5. Input octal data
nOct = int(raw_input('input oct value(like 020):\n'),8)print 'nOct = %o,nDec = %d\n' % (nOct,nOct)
This example provides some learning reference for beginners of Python. If you are interested, you can debug and run this example to deepen your understanding of raw_input usage.
How does one obtain user input in Python?
You can use the input () function.
You can also use the raw_input () function.
Example:
>>> X = input ("x :")
X: 34
>>> Y = input ("y :")
Y: 42
>>> Print x * y
1428
How does python obtain keyboard input?
Content = input ("input :")
Or
Content = raw_input ("input :")
Because python versions are different, the supported input methods (input/raw_inpt) are different.