
正文
python的sep函数 python中的sep参数
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
Python的print函数中的sep参数为什么没有效果?,麻烦大神帮忙看一下,是不是跟for循环有关系
sep是指print中的可变位置参数有多个时,要用什么符号分隔打印这些参数。
运行一下下面的代码,相信你马上就能明白:
print(1, 2, 3, 4, 5, sep='_')
相关问答
Q1: Python,这段代码是什么意思,求解答
这是一个将字符串列表连接到一起的函数。
chList是一个字符串列表,如['abc', 'efg', 'opi']
sep是连接字符串的分隔符
(sep or ',')是指如果sep存在就用sep, 不存在就用,
例如:
chList = ['abc', 'efg', 'opi']
Join(chlist) # 结果为 abc,efg,opi
Join(chlist, ' ') # 结果为abc efg opi
Q2: 在python中,数据的输出用哪个函数名
Python3中使用:print()函数
用法(从IDLE帮助上复制):
print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
value即你要输出的值(大多数类型均可),sep是这多个值用什么分割(默认为空格),end是这个输出的末尾是什么(默认是换行)。
Q3: python3 print函数sep怎么用
分隔符啊python的sep函数,
a = [1, 2, 3]
print(*a, sep='-')
python的sep函数的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于python中的sep参数、python的sep函数的信息别忘了在本站进行查找喔。






