python print函数之end

print函数默认换行,是end=' '在起作用,

print(value, ..., sep=' ', end=' ', file=sys.stdout, flush=False)

案例:

>>> for i in range(10):
print(i)

0
1
2
3
4
5
6
7
8
9

如果不想换行可以用 print(xxx,end='')

案例:

>>> for i in range(10):
print(i,end='')

0123456789

如果想打印制表符用print(xxx,end=' ')

案例:

>>> for i in range(10):
print(i,end=' ')  # 不换行,数字之间打印制表符

0   1   2   3   4   5   6   7   8   9

案例:

>>> for i in range(10):
print(i,end='**')           #不换行,结尾后追加**

0**1**2**3**4**5**6**7**8**9**

原文地址:https://www.cnblogs.com/znh8/p/9310225.html