Python多行打印
我们通常在python中看到print命令打印一行输出。但是,如果要打印多行,则采用这种方法需要编写多个打印命令。可以通过使用另一种涉及三个单引号的技术来避免这种情况,如下所示。
示例
print('''
Motivational Quote :\n
Sometimes later becomes never, Do it now.
Great things never come from comfort zones.
The harder you work for something, the greater you'll feel when you achieve it.
''')运行上面的代码将为我们提供以下结果:
Motivational Quote : Sometimes later becomes never, Do it now. Great things never come from comfort zones. The harder you work for something, the greater you'll feel when you achieve it.
我们可以使用多行打印来生成格式正确的文本,如下所示。
示例
print('''
===========================================
|| ||
|| WORK ||
|| HARD ||
|| ||
|| ||
|| ||
===========================================
''')运行上面的代码将为我们提供以下结果:
============================= || || || WORK || || HARD || || || || || || || =============================
热门推荐
10 最真的新春祝福语简短
11 51祝福语毕业文案简短
12 整形机构开业祝福语简短
13 开店送礼祝福语大全简短
14 买房的祝福语高级简短
15 男孩上学祝福语简短英语
16 老板辞职后祝福语简短
17 虎年新年专属祝福语简短
18 银行考研上岸祝福语简短