Python print() Function
Description
print()The method is used for printing output and is the most common function.
In Python 3.3, the flush keyword parameter was added.
print is a function in Python 3.x, but in Python 2.x it is not a function; it is just 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 that multiple objects can be output at one time. When outputting multiple objects, they need to be separated by ,.
- sep -- Used to separate multiple objects; the default value is a space.
- end -- Used to set what to end with. The default value is the newline character \n, which can be changed to other strings.
- file -- The file object to be written to.
- flush -- Whether the output is buffered usually depends on file, but if the flush keyword parameter is True, the stream will be forcibly flushed.
Return Value
None.
Examples
The following shows examples of using the print function:
Test on Python3
>>>print(1)
1
>>> print("Hello World")
Hello World
>>> a = 1
>>> b = 'example'
>>> print(a,b)
1 example
>>> print("aaa""bbb")
aaabbb
>>> print("aaa","bbb")
aaa bbb
>>>
>>> print("www","example","com",sep=".") # Set the separator
www.example.com
Use the flush parameter to create a Loading effect:
Examples
import time
print("---EXAMPLE EXAMPLE: Loading effect---")
print("Loading",end = "")
for i in range(20):
print(".",end = '',flush = True)
time.sleep(0.5)
print("---EXAMPLE EXAMPLE: Loading effect---")
print("Loading",end = "")
for i in range(20):
print(".",end = '',flush = True)
time.sleep(0.5)
The effect is as shown in the figure below:

For more information, see:Python3 print Function Usage Summary
Other Extensions
Python3 Built-in Functions