您现在的位置是:课程教程文章

python sep啥意思

2023-12-18 20:44课程教程文章 人已围观

全称为Separate意为分开、隔开。

用于print两个元素时自定义间隔符(默认为两个空格)

关键字参数sep是实现分隔符,比如多个参数输出时想要输出中间的分隔字符。

print(1, 2, 3, sep = ',', end = '\r\n')
print(1, 2, 3, sep = ' ', end = '\r\n')

结果输出如下:

1,2,3
1 2 3
print("file\n","abc","bcd","fff\n","poi")
print("-------------")
print("file\n","abc","bcd","fff\n","poi",sep='')
print("-------------")
print("file\n","abc","bcd","fff\n","poi",sep=' ')
print("-------------")

其结果为:

file
 abc bcd fff
poi-------------file
abcbcdfff
poi-------------file
 abc bcd fff
poi-------------

python学习网,大量的免费python视频教程,欢迎在线学习!

课程教程:python sep啥意思

上一篇:python安装的包文件在哪个文件夹

下一篇:没有了

站点信息

  • 文章统计篇文章