看啥推荐读物
专栏名称: Python小屋
清华出版社《Python程序设计》系列教材作者董付国的Python小屋。介绍Python基础语法知识、标准库、扩展库知识,探讨Python在各领域的应用。
今天看啥  ›  专栏  ›  Python小屋

Python基本输出函数print()用法小结

Python小屋  · 公众号  · Python  · 2017-08-07 21:44
Python内置函数print()是基本输出函数,可以使用help()函数查看其详细用法和参数含义:>>> 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.下面演示一下这个函数的几种用法:(1) 输出多个对象的值,改变多个值之间的分隔符# 使用默认分隔符>>> print(1,3,5)1 3 5# 使用指定的分隔符>>> print(1,3,5, sep=',')1,3,5>>> print(1,3,5, sep=':')1:3:5(2 ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照