Python print() Function
Description
print() method is used to print output, and is the most commonly used function.
The flush keyword argument was added in Python 3.3.
print is a function in Python 3.x, but it is not a function in Python 2.x—it is merely a keyword.
Syntax
The following is the syntax of the print() method:
print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
Parameters
- objects -- plural, meaning multiple objects can be output at once. When outputting multiple objects, they must be separated by ,.
- sep -- used to separate multiple objects, the default value is a space.
- end -- used to set what the output ends with. The default value is the newline character \n; it can be changed to another string.
- file -- the file object to write to.
- flush -- whether the output is buffered usually depends on file, but if the flush keyword argument is True, the stream will be force-flushed.
Return Value
none.
Example
The following shows an example of using the print function:
Tested under Python3
(
1
)
1
(
"
Hello World
"
)
Hello
World
a
=
1
b
=
'
runoob
'
(
a
,
b
)
1
runoob
(
"
aaa
"
"
bbb
"
)
aaabbb
(
"
aaa
"
,
"
bbb
"
)
aaa
bbb
(
"
www
"
,
"
runoob
"
,
"
com
"
,
sep
=
"
.
"
)
Set the separator
www
.
runoob
.
com
Use the flush parameter to create a Loading effect:
Example
import
time
(
"---RUNOOB EXAMPLE : Loading effect---"
)
(
"Loading"
,
end
=
""
)
for
i
in
range
(
20
)
:
(
"."
,
end
=
''
,
flush
=
True
)
time
.
sleep
(
0.5
)
The effect is shown in the figure below:

For more information, refer to:Python3 print Function Usage Summary
Python3 built-in function