内建函数print(python3.0)

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
打印 objects 到文本流对象 file,以 sep 为分隔符,以 end 为结尾符。如果要提供 sep, endfile 这三个参数的话,必须使用键值对的形式。
仅在python3.0环境适用。
1、sep分隔符:
1 print(x,y,sep='#',end='\n')
View Code

显示结果:

1#2

 

2、end结尾符,end默认为换行符‘\n’:

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))
View Code

显示结果:

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

posted on 2016-04-15 14:23  guoqp  阅读(396)  评论(0编辑  收藏  举报

导航