age = raw_input("How old are you? ")
height = raw_input("How tall are you? ")
weight = raw_input("How much do you weigh? ")
print "So, you're %r old, %r tall and %r heavy." %(
age, height, weight)
print "So, you're %s old, %s tall and %s heavy." %(
age, height, weight)
"""
Test Result:
How old are you? 31
How tall are you? 174
How much do you weigh? 80
So, you're '31' old, '174' tall and '80' heavy.
So, you're 31 old, 174 tall and 80 heavy.
"""
心得:
这是我喜欢的raw_input方式
本文展示了一个使用Python获取用户年龄、身高和体重,并以不同格式输出数据的简单程序。
5358

被折叠的 条评论
为什么被折叠?



