Excercise 6|learn python the hard way

%s 表示為字符替代符號
%r 表示為引號+字符替代符號

今日練習。
http://learnpythonthehardway.org/book/ex6.html

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 = False
joke_evaluation = "Isn't that joke so funny?! %r"

print (joke_evaluation % hilarious)

w = "This is the left side of ..."
e = "a stromg wotj a rogjt side."

print (w + e)

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容