Home > Backend Development > Python Tutorial > Python的print用法示例

Python的print用法示例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 11:29:16
Original
1240 people have browsed it

Python 2.6中print不是函数,而是一个关键字,使用方式如下:

代码如下:


print 1, 2 
print 'a', 'b' 


显示结果如下,用逗号分隔的各项之间会打印出一个空格,默认以换行结束:

代码如下:


1 2 
a b


若不想以换行结束,则在最后加一个“,”,如下所示:

代码如下:


print 1, 2, 
print 'a', 'b'

显示结果如下:

代码如下:


1 2 a b


Python 3.0中print变成了一个内置函数
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template