如何用python3输出print函数?
最近函数讲的比较多,小编知道大家对函数的热情很高,所以趁热打铁想扩展一些知识内容。毕竟大家对print函数不算陌生,用的也算是频繁。不知道大家有没有学过输出print函数方面的知识,今天小编要带来的内容正是这个,听过的小伙伴也可以温习一遍,没学过的可就要认真仔细看啦~
在python中,我们一般用print() 输出,在括号里输入你想输出的信息,用引号包裹起来(单双三都可以),例如我们来输出一个’hello,python’
>>>print('hello,python') >>>hello,python >>>print("hello,python") >>>hello,python
如果要输出多个字符串,可以这样做:用逗号隔开的话每个字符串中间会以空格分隔
>>>print('hello', 'world', 'python') >>>hello world python
也可以这样做,用加号连接的话每个字符串之间没有任何连接符,直接放在了一起
>>>print('hello' 'world' 'python') >>>helloworldpython print还可以用来输出数字—输出数字的时候不用加引号包裹 >>>print(20) >>>20
也可用来计算数字之间的算数运算
>>>print(20 20) >>>40
关于print有两个常用的内置方法
end会在输出内容的最后加上指定的字符,其实如果不指定end的值的话,默认为换行符也就是\n。所以print两次的话,是显示为两行,而不是显示在一行
>>>print('hello', end='#') >>>hello#
sep会以指定的字符来连接print中的内容
>>>print('hello', 'world', 'python', sep='@') >>>hello@world@python
以上就是python3输出print函数的一些方法。虽然大家print函数学了不少,今天也算增加了一点新的基础知识了。上面的代码可以直接使用,多练习才能出成果。
您可能感兴趣的文章:
python2和3print的区别
如何用python3输出print函数?
2019年python学3还是2
python怎么打印字符
python2和python3中print有什么区别
python3怎么获取控制台输入的数据
Python如何输出和输入
python3中怎么让print输出不换行
python怎么删除字符
python3怎么调用map函数