在Python中,`end`参数用于`print`函数,用来指定在打印文本后添加的内容。默认情况下,`print`函数会在输出文本后自动添加一个换行符(`'\n'`),这样每次调用`print`函数都会开始新的一行。如果你不希望每次打印后都换行,而是希望在当前行继续打印,你可以将`end`参数设置为一个空字符串(`''`)。
例如:
print("Hello, World!", end='') 输出 "Hello, World!",并且不会换行
print("This is on the same line.") 输出 "This is on the same line.",并且不会换行
这样,`print`函数就会在当前行的末尾添加一个空字符串而不是换行符,从而实现文本在同一行输出。