admin 管理员组

文章数量: 1086019


2024年3月26日发(作者:java在线编程菜鸟工具)

print函数python源码

以下是Python中print函数的源码:

```python

def print(*objects, sep=' ', end='n', file=, flush=False):

"""

Print objects to the text stream file, separated by sep and followed

by end.

sep, end, file and flush, if present, must be given as keyword

arguments.

"""

if sep is None:

sep = ' '

if end is None:

end = 'n'

if file is None:

file =

if flush:

()

print_sep = str(sep).join(str(object) for object in objects)

print_end = str(end)

(print_sep + print_end)

```

此源代码定义了print函数,它接受任意数量的参数,并将它们打

印到指定的文本流中。默认情况下,参数之间用空格分隔,以换行

符结尾。如果指定了关键字参数sep、end、file或flush,则使用提

供的值来分隔、结束、输出文件或刷新输出。


本文标签: 参数 函数 输出 编程 分隔