2010-06-05 47 views
5

在Python 2.x中,我会写......输出,Py3k

for i in range(5): 
    print i, 

...拿到0-4的整数同一行中打印。如何在Python 3.x中做到这一点,因为print现在是一个函数?

回答

7

使用print(x, end = ' ')

release notes

Old: print x,   # Trailing comma suppresses newline 
New: print(x, end=" ") # Appends a space instead of a newline