練習(xí)11-提問
- 練習(xí)程序
- 課后練習(xí)
練習(xí)程序
# -*- coding: utf-8 -*-
#raw_input(),原始字符%r格式輸出
print "How old are you?",
age = raw_input()
print "How tall are you?",
height = raw_input()
print "How much do you weigh?",
weight = raw_input()
print "So, you're %r old, %r tall and %r heavy." % (
age, height, weight)
#raw_input(),字符串格式%s輸出
print "你多大啦励负?",
age = raw_input()
print "你多高",
height = raw_input()
print "你多重",
weight = raw_input()
print "So,你有%s歲了,你身高有%s,你體重有%s"%(age,height,weight)
#in_put()
print "你多大啦莹汤?",
age = input()
print "你多高",
height = input()
print "你多重",
weight = input()
print "So,你有%r歲了,你身高有%r,你體重有%r"%(age,height,weight)
運(yùn)行結(jié)果
RESTART: F:\python大師\習(xí)題\ex11.py
How old are you? 29
How tall are you? 178cm
How much do you weigh? 65kg
So, you're '29' old, '178cm' tall and '65kg' heavy.
你多大啦蛾派? 29歲
你多高 1米78
你多重 130斤
So,你有29歲歲了,你身高有1米78,你體重有130斤
你多大啦吩翻? 29
你多高 "1米78"
你多重 "65公斤"
So,你有29歲了,你身高有'1\xc3\xd778',你體重有'65\xb9\xab\xbd\xef'
課后練習(xí)
What's the difference between input() and raw_input()?
The input() function will try to convert things you enter as if they were Python code, but it has security problems so you should avoid it.
其他課后練習(xí)及問題就不看了净蚤,主要網(wǎng)上找資料對(duì)比了一下input和raw_input的區(qū)別,前者說白了接收到的內(nèi)容直接按照python格式處理了共屈,比如接收一個(gè)數(shù)字其實(shí)就是int或者float類型的绑谣,而如果接收一個(gè)字符串必須加字符串標(biāo)志引號(hào),后者對(duì)于輸入的內(nèi)容都會(huì)處理成字符串拗引,哪怕只是輸入一個(gè)數(shù)字借宵,其實(shí)也是被當(dāng)成一個(gè)字符串在處理的,我的本節(jié)課程序也用此處擴(kuò)展了一些,也能從中看出來