Display string multiple times

I want to print a character or string like '-' n number of times.

Can I do it without using a loop?.. Is there a function like

print('-',3)

..which would mean printing the - 3 times, like this:

---
182674 次浏览

Python 2. x:

print '-' * 3

Python 3. x:

print('-' * 3)

可以接受的答案是简短而甜蜜的,但是这里有一个替代语法,它允许在 Python 3.x 中提供一个分隔符。

print(*3*('-',), sep='_')