关闭

exercise11

标签: python
82人阅读 评论(0) 收藏 举报
分类:

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
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:3978次
    • 积分:393
    • 等级:
    • 排名:千里之外
    • 原创:38篇
    • 转载:3篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档