Python的print函数多参数使用方法

 剑鱼论坛 发表于 2019年12月11日 Python  118
剑鱼论坛
LV 8 研究生
最后在线:2年前
加入时间:5年前
主帖:143  跟帖:100

Python语言中使用“print”函数来打印输出是常见的用法,例如,我们可以使用如下代码进行输出:

print("剑鱼论坛")

上面的代码就可以在屏幕上输出“剑鱼论坛”这几个字,我们这里的输出是单一参数的,事实上Python语言的print输出可以是多参数的,看下面的代码:

print("JianYuLunTan","source","code","is","good")

上面这行语句会在屏幕上输出如下内容:

JianYuLunTan source code is good

我们发现Python的输出自动在每个参数之间加了空格,这个在字母型语言的输出中是比较有用的,但在中文的输出方面似乎不太需要,因为中文的文字之间是不需要空格的,而类似英语这样的字母型语言,每个单词之间是需要空格来分隔的。

您可以在print里面加任意多的参数,输出时就会在每个参数之间加空格输出。

论坛主帖
288
论坛跟帖
316
在线访客
1
今日主帖
0
今日跟帖
0
今日注册
0
31
http://jianyuluntan.com/gentie.html
http://jianyuluntan.com/postzan.html
http://jianyuluntan.com/postcai.html
http://jianyuluntan.com/postshoucang.html
http://jianyuluntan.com/gentiezan.html
http://jianyuluntan.com/gentiecai.html
http://jianyuluntan.com/huifu.html
http://jianyuluntan.com/xiugai.html
http://jianyuluntan.com/shanchugentie.html
1
XzA=
1
© 2019 - 2024 剑鱼论坛 版权所有
Powered by JianYuLunTan
剑鱼论坛 976666861
http://jianyuluntan.com/feedback.html
http://jianyuluntan.com/qiandao.html
http://jianyuluntan.com/denglu.html
0
http://jianyuluntan.com/adenglu.html
0
剑鱼论坛