In this paper, the usage of raw_input in Python is introduced in detail, and the data can be read by using Raw_input, which is convenient for the bundle console. Examples of specific uses are as follows:
1. Input string
#13222319810101 * * *
NID = ' while
1:
NID = raw_input ("Input your id plz")
if Len (NID)!= len ("1322231981 0101**** "):
print ' wring length of id,input again '
else:
break
print ' Your ID is%s '% (NID)
2. Input integer
nage = Int (raw_input ("Input your Age plz:\n")
if nage > 0 and Nage <:
print ' thanks! '
else:
print ' bad age '
print ' your '%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
4. Enter 16 data
Nhex = Int (raw_input (' Input hex value (like 0x20): \ n ')
print ' Nhex =%x,noct =%d\n '% (Nhex,nhex)
5. Enter 8 data
noct = Int (raw_input (' Input Oct value (like 020): \ n '), 8)
print ' noct =%o,ndec =%d\n '% (noct,noct)
This article examples of Python beginners have a certain learning value, interested readers can start debugging run a sample of this article to deepen the understanding of raw_input usage.