end: 默認是換行,表示兩個字符串最后以什么結尾。
eg: 換行 end="\n"
sep: 默認是空格,表示兩個字符串之間用什么分割。
eg: 空格 sep=" "

補充:python 中的 print(x, end=) 和 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):
print(i, end=" ")
輸出結果:
0 1 2 3 4 5 6 7 8 9
參數 end 默認打印換行, 即 end = "\n"
sep 用于做打印拼接
print("hello", "world", sep=":")
打印結果:
hello:world
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:- python不換行之end=與逗號的意思及用途
- Python sep參數使用方法詳解
- 一文秒懂python中的 \r 與 end=‘’ 巧妙用法