Home > Article > Backend Development > What does 'end=' mean in python?
In python, "end=" is a parameter in the "print()" function, which will cause the function to turn off the default behavior of "automatically including newlines in the output". By default, print prints a line with a newline at the end. end passes an empty string to indicate that the statement has not ended.
"end=" as a parameter in print() will cause the function to turn off the default behavior of "automatically include newlines in the output" .
Pass an empty string for end, so that the print function will not add a newline character at the end of the string, but add an empty string. In fact, this is also a grammatical requirement, indicating that this statement It's not over.
Print defaults to printing one line with a newline at the end. end=' ' means no line break at the end, add a space
As shown below: Use a for loop to implement the multiplication table: (Use end=' ') Gradient display prints one line, add a line break at the end
for i in range(1, 10): for j in range(1, i + 1): print('{}x{}={}\t'.format(j, i, i * j), end='' ) print('\n')
Recommended tutorial: "python tutorial"
The above is the detailed content of What does 'end=' mean in python?. For more information, please follow other related articles on the PHP Chinese website!