print() Print to stdout

Last updated: 2026-09-22

print() Print to stdout

print() writes objects as strings to stdout (default); sep joins them, end is appended, file redirects output.

CategoryBuilt-in Functions
KindBuilt-in Function
Python Versionall

📝 Syntax

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)

⚙️ Parameters

objects OptionalZero or more objects to print (variadic), converted to strings automatically.
sep OptionalSeparator inserted between objects, default a space.(Default:' ')
end OptionalString appended at the end, default a newline.(Default:\n)
file OptionalOutput target; must have a write method.(Default:sys.stdout)
flush OptionalWhether to flush the stream immediately.(Default:False)

Returns:Returns None; output is written to the stream given by file.

▶ Example

Edit the code, press Run, and see the result in the output panel:

Output:

hello
a-b-c
no newline here
More case studies coming soon — check back later.

❓ FAQ

QWhat does print('a', 'b', 'c', sep='-') output?
AIt outputs a-b-c. sep sets the separator between multiple objects, which defaults to a space.
QHow do I print without a newline?
APass end='': print('x', end='') prints without a newline so the next print continues on the same line; end defaults to '\n'.
QCan print() output to a file?
AYes, print('text', file=f) writes to a file object, or print(..., file=sys.stderr) outputs to the standard error stream.
QWhat does print() return? What is the flush parameter for?
Aprint() returns None, so do not use it as a return value. flush=True immediately flushes buffered content to the output stream, useful for progress bars and real-time logging.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏