2017-10-17 90 views
-1

您好我有一個簡單的代碼:這裏逗號是什麼?

for i in range(0, 10): 
    print '\b*' 

輸出:

* 

* 

* 

* 

* 

* 

* 

* 

* 

* 
然而

當我在末尾添加一個逗號像這樣:

for i in range(0, 10): 
    print '\b*' , 

輸出是:

********** 

究竟是什麼在這裏做的逗號\ b?

+0

'print x'表示輸出'x',然後是換行符。 'print x,'表示輸出'x',然後是空格。 – khelwood

+0

你有沒有試過[閱讀文檔](https://docs.python.org/2.7/)? [關於'print'語句]部分(https://docs.python.org/2.7/reference/simple_stmts.html#the-print-statement)可能會有用。 –

+0

結果從您的示例中不明顯? –

回答

1

按照文檔here

A '\ n' 字符在年底寫的,除非 print語句以逗號結束。