成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

聊聊Python中end=和sep=的區(qū)別

瀏覽:7日期:2022-06-19 15:00:50

end: 默認(rèn)是換行,表示兩個字符串最后以什么結(jié)尾。

eg: 換行 end='n'

sep: 默認(rèn)是空格,表示兩個字符串之間用什么分割。

eg: 空格 sep=' '

聊聊Python中end=和sep=的區(qū)別

補(bǔ)充:python 中的 print(x, end=) 和 print(x, sep=)

print(x, end=)for i in range(10): print(i)

輸出結(jié)果:

0 1 2 3 4 5 6 7 8 9

for i in range(10):

print(i, end=' ')

輸出結(jié)果:

0 1 2 3 4 5 6 7 8 9

參數(shù) end 默認(rèn)打印換行, 即 end = 'n'

print(x, sep=)

sep 用于做打印拼接

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

打印結(jié)果:

hello:world

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章: