Use of Python print function

The complete usage of the print function in Python is as follows:

print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
  • objects: This is the main output content of the print function, which can be one or more objects, such as strings, numbers, variables, etc. When multiple objects are passed in, the print function will print out the values ​​of these objects in sequence.
  • sep: used to define the separator when printing multiple objects, the default is a space ' '. For example, print(‘Hello’, ‘world’, sep=’, ') will output Hello, world.
  • end: used to define the end character after printing ends. The default is the newline character ‘\n’. For example, print(‘Hello, world’, end=‘!’) will print Hello, world!.
  • file: Defines the output location of the print function. The default is the standard output stream sys.stdout, which is the console. You can also specify other files or I/O streams.
  • flush: Boolean value that controls whether output is flushed to the file immediately. Default is False.

Guess you like

Origin blog.csdn.net/hanmo22357/article/details/134711145