书本练习题5print函数使用

注意%d %s 一 一对应
my_name = 'Zed A.Shaw'

my_age = 35 # not a lie
my_height = 74 # inches
my_weight = 180 # lbs
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Brown'
print("Let's talk about %s." % my_name )
print("He's %d inches tall." % my_height)
print("He's %d pounds heavy." % my_weight)
print("Actually that's not too heavy.")
print("He's got %s eys and %s hair." % (my_eyes ,my_hair))
print("Hes teeth are usuallly %s depending on the coffee."% my_teeth)

#this line is tricku,tre to get it exactly right
print("If I add %d,%d, and %d I get %d." % (my_age,my_height,my_weight,my_age + my_height + my_weight) )
如果出现 TypeError: not enough arguments for format string
就是缺少了 格式字符串的参数,
posted @ 2019-06-18 22:44  犀利犀利  阅读(120)  评论(0编辑  收藏  举报