Python Glossary Русский

all Python 3Input & outputterm

sep=

output

Parameter of print() that sets the separator between arguments. Defaults to a space. Can be any string, including an empty one.

Syntax

print(*objects, sep='разделитель')

The separator goes only BETWEEN arguments, so with a single argument sep does nothing: print(nums, sep=", ") prints the list with its brackets — unpack it with a star or build the string with str.join() instead. What comes after the last item is end's job, not sep's. The value must be a string or None: sep=0 raises TypeError.

Examples

print(1, 2, 3, sep=", ")  # → 1, 2, 3
print("a", "b", "c", sep="")  # → abc
print("год", "месяц", "день", sep="-")  # → год-месяц-день
print(10, 20, 30, sep="\n")  # каждое число на новой строке
print(*[1, 2, 3, 4], sep=" | ")  # → 1 | 2 | 3 | 4

See also

Open in the full glossarydocs.python.orgReport an inaccuracy