Python打印print函数深入解析
2016-07-17 01:17
531 查看
Python的print函数细节
尊重劳动成果,请访问CSDN著者原文链接 http://blog.csdn.net/zixiao217/article/details/51929078学会在IDLE中使用help(BIF)命令查看BIF的说明
>>> help(print) Help on built-in function print in module builtins: print(...) print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default. Optional keyword arguments: file: a file-like object (stream); defaults to the current sys.stdout. sep: string inserted between values, default a space. end: string appended after the last value, default a newline. flush: whether to forcibly flush the stream.
上面的代码通过help(print)查看BIF print的用法以及说明:
print的效用:Prints the values to a stream, or to sys.stdout by default.—将值以流的形式输出,或者使用默认打印在控制台
print函数参数列表:
参数 | 说明 |
---|---|
value | 是要打印的值 |
… | 值列表,表示可以一次性打印多个值 |
sep | string inserted between values, default a space.——表示打印值时,各个值之间的间隔符,默认是一个空白字符 |
end | string appended after the last value, default a newline.——打印完最后一个值需要添加的字符串,默认是换行符,即打印完会跳到新行 |
file | a file-like object (stream); defaults to the current sys.stdout.——将值打印到一个文件流对象,默认是打印到控制台 |
flush | whether to forcibly flush the stream.——是否强制冲刷流 |
>>> print("值一", "值二", "值三") 值一 值二 值三 >>> print("字符串", 2, 1 + 2j) # 同时打印字符串、int、复数 字符串 2 (1+2j)
相关文章推荐
- python 实现 knn分类算法 (Iris 数据集)
- python内置函数 2
- 配置python tab键自动补全
- 【转】开篇python--明白python文件如何组织,理解建立源文件
- Python读取文件
- Learning Python 008 正则表达式-003 sub()方法
- Python入门笔记之字符串
- 如何在 Python 3.4 上安装 python-docx
- Learning Python 008 正则表达式-004 sub()方法
- python 关于多线程那些事
- 怎么样才算是精通 Python?
- Learning Python 008 正则表达式-003 search()方法
- Learning Python 008 正则表达式-003 search()方法
- Python序列——元组
- 最简洁最没有废话的python入门教程
- Python if..else
- python网络画图——networkX
- Learning Python 008 正则表达式-002 findall()方法
- Learning Python 008 正则表达式-002 findall()方法
- Python序列——列表