An application in the Python programming language can read input values. This is a very important application technology used in actual operations. Here, we will give you a detailed introduction to the application skills related to reading input values from Python, hoping to help you.
The following describes the usage of python raw_input. Using raw_input can easily read data in the cluster console.
Operation Method for reading input values in Python 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)
Operation Method for reading input values in Python 2. Input 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.0
- fWeight = float(raw_input("input your weight\n"))
- print 'your weight is %f' % fWeight
Python Operation Method for reading input values 4. Input hexadecimal data
- nHex = int(raw_input('input hex value(like 0x20):\n'),16)
- print 'nHex = %x,nOct = %d\n' %(nHex,nHex)
Operation Method for reading input values in Python 5. Input octal data
- nOct = int(raw_input('input oct value(like 020):\n'),8)
- print 'nOct = %o,nDec = %d\n' % (nOct,nOct)