關鍵字end能夠用於將結果輸出到同一行,或者在輸出的末尾添加不一樣的字符,實例以下:spa
end
a, b = 0, 1 while b < 1000: print(b, end=',') a, b = b, a+b
執行以上程序,輸出結果爲:code
1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,