好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

聊聊Python中end=和sep=的区别

end: 默认是换行,表示两个字符串最后以什么结尾。

eg: 换行 end="\n"

sep: 默认是空格,表示两个字符串之间用什么分割。

eg: 空格 sep=" " HdhCmsTestcppcns测试数据

补充:python 中的 print(x, en 编程客栈 d=) 和 print(x, sep=)

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):

pJQABgIVvDPrint(i, end=" ")

输出结果:

0 1 2 3 4 5 6 7 8 9

参数 end 默认打印换行, 即 end = "\n"编程客栈

print(x, sep=)

sep 用于做打印拼接

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

打印结http://HdhCmsTestcppcns测试数据果:

hello:world

以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。

查看更多关于聊聊Python中end=和sep=的区别的详细内容...

  阅读:39次