L11:
书中代码:
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
)
代码修改为:
print(“How old are you?”)
age = input()
print(“How tall are you?”)
height = input()
print(“How much do you weigh?”)
weight = input()
print("So, you're %r old, %r tall and %r heavy." % (
age, height, weight
))
结果输出:
How old are you?
30
How tall are you?
180
How much do you weigh?
78
So, you’re ‘30’ old, ‘180’ tall and ‘78’ heavy.
附加题:
1、上网查一下 Python 的 raw_input 实现的是什么功能?
python 3.0之后,不区分input()和raw_input(),统一为input(),默认的返回格式为字符串。
2、你能找到它的别的用法吗&