1、print里面的反斜杠
2、如果希望得到跨越多行的字符串,则可用三重引号字符串
3、格式化字符串 format string
my_name = 'Zed A. Shaw'
my_age = 35
my_height = 74
my_weight = 180
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 eyes and %s hair." %(my_eyes,my_hair)
print "His teeth are usually %s depending on the coffee." % my_teeth
输出结果:
双重格式化:
x = "There are %d types of people." %10
print x
print "I said: %r." %x
%r和%s
%r是用来做调试(debug)比较好,因为它会显示变量的原始数据(raw data),而%s和其他的符号是用来向用户显示输出的。
4、带运算符的打印
print "."*10
end1="Y"
end2="J"
print end1+end2