exercise11


print"How old are you?",   #print 后面逗号表示 在屏幕显示的时候 键入在同一行,如果没有逗号 键入会新起一行
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)




关于%s和%r的区别
利用exercise6的例子 test1、2的用法
binary='binary'
do_not="don't"
字符串y= 'those who knows %s and those who %s' %(binary, do_not)

用%s格式符—— print y 后 显示:
those who knows binary and those who don't
 用%r格式符——print y 显示:
those who knows 'binary' and those who "don't"

总结:
%s显示字符串内容, 而%r显示字符串 包括字符串前面的”“
%r prints it the way you'd write it in your file, but %s prints it the way you'd like to see it?

Remember %r is for debugging and is "raw representation" while %s is for display
阅读更多
文章标签: python
个人分类: 自学
上一篇exercise 10
下一篇exercise 12 提示
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭