python的print默认带换行,刚学自己不会,度了下,发现这个好用:
开头加(python v3.7下测试不需要这条):
from __future__ import print_function
print输出是加“,end='' ”:
print(xx,end=' ')
eg:
from __future__ import print_function
#九九乘法口诀表
for x in range(0,10):
for y in range(1,x+1):
print(str(y)+"*"+str(x)+"="+str(x*y),end=' ')
print("")
DemodeMacBook-Air:~ demo$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>