多次显示字符串 [英] Display string multiple times
本文介绍了多次显示字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打印一个字符或字符串,比如 '-' n 次.
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)
..这意味着将 -
打印 3 次,如下所示:
..which would mean printing the -
3 times, like this:
---
推荐答案
Python 2.x:
Python 2.x:
print '-' * 3
Python 3.x:
Python 3.x:
print('-' * 3)
这篇关于多次显示字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文