Print in one line dynamically

后端 未结 20 3233
梦谈多话
梦谈多话 2020-11-21 23:32

I would like to make several statements that give standard output without seeing newlines in between statements.

Specifically, suppose I have:

for it         


        
20条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-22 00:04

    Change print item to:

    • print item, in Python 2.7
    • print(item, end=" ") in Python 3

    If you want to print the data dynamically use following syntax:

    • print(item, sep=' ', end='', flush=True) in Python 3

提交回复
热议问题