python中的print(x, end=)和print(x, sep=)

时间:2018-06-09 11:41:21   收藏:0   阅读:1711

print(x, end=)

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

输出结果:

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

参数end默认打印换行,即end = “\n”

 


 

 

print(x, sep=)

sep用于做打印拼接

print("hello", "world", sep=":")

打印结果:

hello:world

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!