Learn Python the Hard Way 7: Ex05 More Variables and Printing

来源:互联网 发布:淘宝众划算怎么样 编辑:程序博客网 时间:2024/06/02 00:36

7 Ex05 More Variables and Printing

7.1 格式化输出字符串

# -*- coding: utf-8 -*my_name = 'Zed A. Shaw'my_age = 35 # not a liemy_height = 74 # inchesmy_weight = 180 # lbsmy_eyes = 'Blue'my_teech = 'White'my_hair = 'Brown'print "Let'talk about %s." %my_name #注意没有逗号print "He's %d inches tall." %my_heightprint "Actually that's not too heavy."print "He's got  %s eyes and %s hair." %(my_eyes, my_hair)print "His teeth are usually %s depending on the coffee." %my_teech# this line is tricky, try to get it exactly rightprint "If I add %d, %d, and %d I get %d." %(my_age, my_height, my_weight, my_age + my_height + my_weight)

这是你应该得到的输出:
这里写图片描述

0 0
原创粉丝点击