Python Glossary Русский

all Python 3Input & outputterm

end=

output

Parameter of print() that sets the string appended after the output. Defaults to the newline character '\n'. Lets you print on a single line.

Syntax

print(*objects, end='строка')

sep goes between the arguments, while end is appended once after all of them — a pair that gets mixed up constantly. With end="" the text sits in the stdout buffer until a newline appears, so console progress indicators add flush=True; end itself accepts any string, including "\r" or several characters at once.

Examples

print("Загрузка", end="..."); print("готово")  # → Загрузка...готово
for i in range(5): print(i, end=" ")  # → 0 1 2 3 4
print("строка без переноса", end="")  # курсор остаётся на той же строке
print("раз", end="\t"); print("два")  # → раз	два
print("конец", end="!\n")  # → конец!

See also

Open in the full glossarydocs.python.orgReport an inaccuracy