您当前的位置:首页 > IT编程 > python
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:聊聊Python中end=和sep=的区别

51自学网 2021-10-30 22:40:17
  python
这篇教程聊聊Python中end=和sep=的区别写得很实用,希望能帮到您。

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"

print(x, sep=)

sep 用于做打印拼接

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

打印结果:

hello:world

以上为个人经验,希望能给大家一个参考,也希望大家多多支持51zixue.net。


如何用python抓取B站数据
windowns使用PySpark环境配置和基本操作
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。