- print(*objects, sep=' ', end=' ', file=sys.stdout, flush=False)
- 打印 objects 到文本流对象 file,以 sep 为分隔符,以 end 为结尾符。如果要提供 sep, end 和 file 这三个参数的话,必须使用键值对的形式。
- 仅在python3.0环境适用。
- 1、sep分隔符:
1 print(x,y,sep='#',end=' ')
显示结果:
1#2
2、end结尾符,end默认为换行符‘ ’:
1 for i in range(1,11): 2 print(repr(x).rjust(2), repr(x*x).rjust(3), end=' ') 3 # Note use of 'end' on previous line 4 print(repr(x*x*x).rjust(4))
显示结果:
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000