Python的学习中细节的整理(3):raw_input

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:

input the variable<age>
after input, press <Enter>button
input the variable<height>, and then press <Enter >button

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值