我有一个任务,在Python中创建一个10乘10的表,并且在我的打印函数中使用了末尾“\ t”来防止它创建一个新行。但是,我需要它在10个字符之后开始一个新行。我怎样才能做到这一点?这里是我的代码:在Python中打印表
product = 0
for x in range(1,11):
for y in range(1,11):
product = x * y
print(product, end="\t")
我需要它看起来像这样:
1 2 3 4 5 6 ...
2 4 6 8 10 12 ...
3 6 9 12 15 18 ...
'print()'在内部循环之后。 – zondo
@zondo如果她使用Python的2.x版本怎么办?我宁愿建议'print(“”)'。 – mwarzynski
@mwarzynski:Python 2.x没有'end'关键字,因为'print'不是函数。 – zondo