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 新房开工吉日祝福语简短
12 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短