raw_input的功能,总的来说,就一句: 将输入的内容读入,并且可以将其赋给相关的变量。
具体的说来,可将此功能用于一下几个方面:
**function 1.** just simply put in a value, which will be assigned to certain variable(variables). And this function is to some extent similar as the <cin>functions in C++ programming language:
var_type var_1;
cout <<"input the first variable:";
cin>>var_1;
accordingly, in python programming, we have the similar useage as follows:
print"how old are you?",
age = raw_input()
Pay attention to the ‘comma<,>’at the end of
print"How old are you?",
#please keep in mind not leaving out the comma<,>
#if you want to input a value by means of reminding,
#ie, a scentence shown on the screen tells you to input something ,and you input it.
age= raw_input();
print "How tall are you?",
height = raw_input();
print "you are %r old, and %r tall."%(age, height)
Running output:
year = raw_input();
print "year now is: %r" %year
Running output:
>
function 2. using raw_input( ) scentences to remind others somthing:
age = raw_input("How old are you? ")
height = raw_input("how tall are you? ")
print "you are %r old and %r tall" %(age, height)
Running output: