Python中end的使用方法详细解释
方法/步骤
1
首先打开JUPTER NOTEBOOK,新建一个空白的PY文档
2
print("first line")
print("second line")
print("third line")
一般来说,如果直接打印字符串,那么就会自动换行
3
print("first line", end = " ")
print("second line", end = " ")
print("third line", end = " ")
如果用end,就可以定义为同一行,空格间隔
4
print("first line", end = "")
print("second line", end = "")
print("third line", end = "")
如果不设置为空败注泛格的话,全部回合并五王在一起,一般来说不方便观看叮侵
5
print("first line", end = "ABC")
print("second line", end = "CCC")
print("third line", end = "GWE")
当然字符串间隔可以以字符串来定义
6
print("first line", end = "*")
print("second line", end = "*")
print("third line", end = "*")
也可以用其它符号,例如星号来间隔
7
print("first line", end = ", ")
print("second line", end = ", ")
print("third line", end = ", ")
如果用逗号来间隔,那么就看起来像列表一样
8
print("first line", end = "\n")
print("second line", end = "\n")
print("third line", end = "\n")
如果用\n,那么就相当于没有任何变化。
END温馨提示:经验内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。免责声明:本文转载来之互联网,不代表本网站的观点和立场。如果你觉得好欢迎分享此网址给你的朋友。转载请注明出处:https://www.i7q8.com/jiaoyu/9600.html