这是我读《Learn Python The Hard Way》所做的练习,如果有错误请指正。
#create a variable with string and use format character
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)
#display x
print x
print y
#display"I said:" and variable x
print "I said: %r." % x
print "I also said: '%s'." % y
#create a variable named 'hilarious'
#and assign it a value of False "Boolean values"
hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"
#diplay "joke_evaluation" and replace %r with "hilarious"
print joke_evaluation % hilarious
#create two variables named "w" and "e"
w = "This is the left side of..."
e = "a string with a right side."
# display w and e
print w + e
Learning by doing