8 Ex06 Strings and Text
8.1 用一个变量表示字符串
# -*- coding: utf-8 -*
x = "There are %d types of people." %10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." %(binary, do_not)
print x
print y
print "I said: %r." %x
print "I also said: '%s'." %y
hilarious = True
joke_evaluation = "Isn't that so funny?! %r"
print joke_evaluation % hilarious # 不懂
w = "This is the left side of..."
e = "a string with a right side."
print w + e # 在输出语句中的+,表示将字符,字符串连接起来.
这是你应该的输出:
8.2 延伸“
%s
和%r
的区别?
没区别%r
比较好调试.